Subversion Repositories bacoAlunos

Rev

Go to most recent revision | Blame | Compare with Previous | 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 java.io.IOException;

public class PaginasDeleteServlet extends javax.servlet.http.HttpServlet
{


    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 {


        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(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, 1.5.0/docs/api/java/io/IOException.html">IOException {
        doPost(request,response);
    }

}