Example usage for org.hibernate Session flush

List of usage examples for org.hibernate Session flush

Introduction

In this page you can find the example usage for org.hibernate Session flush.

Prototype

void flush() throws HibernateException;

Source Link

Document

Force this session to flush.

Usage

From source file:com.bakeryfactory.cadastros.servidor.FornecedorGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {//  w w w . j a v a  2  s . co m
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        FornecedorVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (FornecedorVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception e) {
        }
    }
}

From source file:com.bakeryfactory.cadastros.servidor.IngredienteGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {/*  w w w . j a  v  a  2 s . c o  m*/
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        IngredienteVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (IngredienteVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception e) {
        }
    }
}

From source file:com.bakeryfactory.cadastros.servidor.ModoPreparoGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {//w w w  .j a  v a  2s .c  o  m
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        ModoPreparoVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (ModoPreparoVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception e) {
        }
    }
}

From source file:com.bakeryfactory.cadastros.servidor.MunicipioGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {/*from w w w.  jav a 2  s  .  c  om*/
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        MunicipioVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (MunicipioVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception ex1) {
        }
    }
}

From source file:com.bakeryfactory.cadastros.servidor.NivelFormacaoGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {//from  w ww  .  java2  s  .  c  o m
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        NivelFormacaoVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (NivelFormacaoVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception ex1) {
        }
    }
}

From source file:com.bakeryfactory.cadastros.servidor.PaisGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {// w  w  w.j a va  2 s .  c o m
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        PaisVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (PaisVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception ex1) {
        }
    }
}

From source file:com.bakeryfactory.cadastros.servidor.PessoaContatoGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {/*from   ww  w  .  ja  v a 2s.c o  m*/
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        PessoaContatoVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (PessoaContatoVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception e) {
        }
    }
}

From source file:com.bakeryfactory.cadastros.servidor.PessoaGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {/*from ww w  .ja  v a2  s. co m*/
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        PessoaVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (PessoaVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception e) {
        }
    }
}

From source file:com.bakeryfactory.cadastros.servidor.ProdutoGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {/* ww  w. j  a  v  a  2  s  .com*/
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        ProdutoVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (ProdutoVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception ex1) {
        }
    }
}

From source file:com.bakeryfactory.cadastros.servidor.ProdutoGrupoGridAction.java

License:Open Source License

private Response delete(Object inputPar, UserSessionParameters userSessionPars, HttpServletRequest request,
        HttpServletResponse response, HttpSession userSession, ServletContext context) {
    Session session = null;
    try {/*from  w  w w  .  j  a v a  2 s . c om*/
        GridParams pars = (GridParams) inputPar;
        ArrayList persistentObjects = (ArrayList) pars.getOtherGridParams().get("persistentObjects");

        ProdutoGrupoVO vo = null;

        session = HibernateUtil.getSessionFactory().openSession();
        session.beginTransaction();

        for (int i = 0; i < persistentObjects.size(); i++) {
            vo = (ProdutoGrupoVO) persistentObjects.get(i);
            session.delete(vo);
            session.flush();
        }
        session.getTransaction().commit();
        return new VOListResponse(persistentObjects, false, persistentObjects.size());
    } catch (Exception ex) {
        if (session != null) {
            session.getTransaction().rollback();
        }
        ex.printStackTrace();
        return new ErrorResponse(ex.getMessage());
    } finally {
        try {
            if (session != null) {
                session.close();
            }
        } catch (Exception ex1) {
        }
    }
}