Blame |
Last modification |
View Log
| RSS feed
package pt.estgp.es.exemplos.hibernate.web;
import pt.estgp.es.exemplos.hibernate.HibernateUtils;
import pt.estgp.es.exemplos.hibernate.Seccao;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Created by joaoe on 29-10-2018.
*/
public class PaginasDeleteServlet
extends HttpServlet
{
protected void doPost
(HttpServletRequest request, HttpServletResponse response
) throws ServletException,
1.5.0/docs/api/java/io/IOException.html">IOException {
1.5.0/docs/api/java/lang/String.html">String idSeccao = request.
getParameter("idSeccao");
HibernateUtils.
getCurrentSession().
beginTransaction();
Seccao seccao =
(Seccao
) HibernateUtils.
getCurrentSession().
load(Seccao.
class,
new 1.5.0/docs/api/java/lang/Long.html">Long(idSeccao
));
1.5.0/docs/api/java/lang/Long.html">Long idPagina = seccao.
getPagina().
getId();
seccao.
getPagina().
getSeccoes().
remove(seccao
);
seccao.
setPagina(null);
HibernateUtils.
getCurrentSession().
delete(seccao
);
HibernateUtils.
getCurrentSession().
getTransaction().
commit();
request.
setAttribute("id", idPagina
);
request.
getRequestDispatcher("apresentaPagina.jsp").
forward(request,response
);
}
protected void doGet
(HttpServletRequest request, HttpServletResponse response
) throws ServletException,
1.5.0/docs/api/java/io/IOException.html">IOException {
doPost
(request,response
);
}
}