Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2007 | 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 javax.servlet.ServletException; |
||
7 | import javax.servlet.http.HttpServlet; |
||
8 | import javax.servlet.http.HttpServletRequest; |
||
9 | import javax.servlet.http.HttpServletResponse; |
||
10 | import java.io.IOException; |
||
11 | |||
12 | /** |
||
13 | * Created by joaoe on 29-10-2018. |
||
14 | */ |
||
15 | public class PaginasDeleteServlet extends HttpServlet { |
||
16 | |||
17 | protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
||
18 | |||
19 | 1.5.0/docs/api/java/lang/String.html">String idSeccao = request.getParameter("idSeccao"); |
||
20 | |||
21 | HibernateUtils.getCurrentSession().beginTransaction(); |
||
22 | |||
23 | Seccao seccao = (Seccao) HibernateUtils.getCurrentSession().load(Seccao.class,new 1.5.0/docs/api/java/lang/Long.html">Long(idSeccao)); |
||
24 | |||
25 | 1.5.0/docs/api/java/lang/Long.html">Long idPagina = seccao.getPagina().getId(); |
||
26 | |||
27 | seccao.getPagina().getSeccoes().remove(seccao); |
||
28 | seccao.setPagina(null); |
||
29 | HibernateUtils.getCurrentSession().delete(seccao); |
||
30 | |||
31 | HibernateUtils.getCurrentSession().getTransaction().commit(); |
||
32 | |||
33 | request.setAttribute("id", idPagina); |
||
34 | |||
35 | request.getRequestDispatcher("apresentaPagina.jsp").forward(request,response); |
||
36 | } |
||
37 | |||
38 | |||
39 | protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException { |
||
40 | doPost(request,response); |
||
41 | |||
42 | } |
||
43 | } |
||
44 |