Subversion Repositories bacoAlunos

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2058 es 1
package pt.estgp.es.exemplos.hibernate.web;
2
 
3
import pt.estgp.es.exemplos.hibernate.HibernateUtils;
4
import pt.estgp.es.exemplos.hibernate.Seccao;
5
 
6
import java.io.IOException;
7
 
8
public class PaginasDeleteServlet extends javax.servlet.http.HttpServlet
9
{
10
 
11
 
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 {
13
 
14
 
15
        1.5.0/docs/api/java/lang/String.html">String idSeccao = request.getParameter("idSeccao");
16
 
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
 
32
 
33
        request.setAttribute("id",idPagina);
34
 
35
        request.getRequestDispatcher("apresentaPagina.jsp").forward(request,response);
36
    }
37
 
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 {
39
        doPost(request,response);
40
    }
41
 
42
}