Subversion Repositories bacoAlunos

Rev

Rev 2005 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2005 Rev 2060
Line 1... Line 1...
1
package pt.estgp.es.exemplos.hibernate.web;
1
package pt.estgp.es.exemplos.hibernate.web;
2
 
2
 
3
import pt.estgp.es.exemplos.hibernate.HibernateUtils;
3
import pt.estgp.es.exemplos.hibernate.HibernateUtils;
-
 
4
import pt.estgp.es.exemplos.hibernate.Pagina;
4
import pt.estgp.es.exemplos.hibernate.Seccao;
5
import pt.estgp.es.exemplos.hibernate.Seccao;
-
 
6
import pt.estgp.es.exemplos.hibernate.services.ServicoPaginas;
5
 
7
 
6
import java.io.IOException;
8
import java.io.IOException;
7
 
9
 
8
public class PaginasDeleteServlet extends javax.servlet.http.HttpServlet
10
public class PaginasDeleteServlet extends javax.servlet.http.HttpServlet
9
{
11
{
Line 12... Line 14...
12
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException {
14
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException {
13
 
15
 
14
 
16
 
15
        1.5.0/docs/api/java/lang/String.html">String idSeccao = request.getParameter("idSeccao");
17
        1.5.0/docs/api/java/lang/String.html">String idSeccao = request.getParameter("idSeccao");
16
 
18
 
17
        HibernateUtils.getCurrentSession().beginTransaction();
-
 
18
 
-
 
19
        Seccao seccao = (Seccao) HibernateUtils.getCurrentSession().load(Seccao.class,new 1.5.0/docs/api/java/lang/Long.html">Long(idSeccao));
-
 
20
 
-
 
21
 
-
 
22
 
-
 
23
        1.5.0/docs/api/java/lang/Long.html">Long idPagina = seccao.getPagina().getId();
-
 
24
 
-
 
25
        seccao.getPagina().getSeccoes().remove(seccao);
-
 
26
        seccao.setPagina(null);
-
 
27
        HibernateUtils.getCurrentSession().delete(seccao);
-
 
28
 
-
 
29
        HibernateUtils.getCurrentSession().getTransaction().commit();
-
 
30
 
-
 
31
 
19
 
-
 
20
        long idPagina = new ServicoPaginas().deleteSeccaoService(idSeccao);
32
 
21
 
33
        request.setAttribute("id",idPagina);
22
        request.setAttribute("id",idPagina);
34
 
-
 
35
        request.getRequestDispatcher("apresentaPagina.jsp").forward(request,response);
23
        request.getRequestDispatcher("apresentaPagina.jsp").forward(request,response);
36
    }
24
    }
37
 
25
 
38
    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException {
26
    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException {
39
        doPost(request,response);
27
        doPost(request,response);