Example usage for org.hibernate Session clear

List of usage examples for org.hibernate Session clear

Introduction

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

Prototype

void clear();

Source Link

Document

Completely clear the session.

Usage

From source file:dao.CampusDAO.java

public static Campus obterCampus(int codigo) throws ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();/*from  w  w w.  j  a v a2  s. c om*/
    session.clear();
    Campus campus = (Campus) session.load(Campus.class, codigo);
    //Campus campus = (Campus)session.createQuery("from Campus where codigoCampus =" + codigo ).list().get(0);

    return campus;
}

From source file:dao.CampusDAO.java

public static List<Campus> obterCampi() throws ClassNotFoundException, SQLException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();//from   w ww.j  ava  2  s .co m
    session.clear();
    List<Campus> campi = session.createCriteria(Campus.class).list();
    return campi;
}

From source file:dao.CampusDAO.java

public static List<Campus> obterCampiPorNome(String nome) throws ClassNotFoundException, SQLException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();// w ww . j av a 2  s.c  om
    session.clear();
    List<Campus> campi = session.createQuery("from Campus where nome like '%" + nome + "%'").list();
    return campi;
}

From source file:dao.CampusDAO.java

public static void gravar(Campus campus) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.save(campus);/*from  w  w w.j  a  va2s .c o  m*/
    transaction.commit();
}

From source file:dao.CampusDAO.java

public static void editar(Campus campus) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.update(campus);/*from  www.  j a v a  2  s .c o  m*/
    transaction.commit();
}

From source file:dao.CampusDAO.java

public static void excluir(Campus campus) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.delete(campus);//from  ww w. j av  a 2  s. c  o  m
    transaction.commit();
}

From source file:Dao.DaoItem.java

public boolean registrarVarios(Session session, List<Item> items) throws Exception {
    for (Item r : items) {
        session.save(r);//from  w  ww . j  a  v a2 s.  c o  m
        session.flush();
        session.clear();
    }
    return true;
}

From source file:Dao.DaoPregConc.java

public boolean registrarVarios(Session session, List<PregConc> resultados) throws Exception {
    for (PregConc r : resultados) {
        session.save(r);/* ww  w  .  j  a  v  a2 s  . c  om*/
        session.flush();
        session.clear();
    }
    return true;
}

From source file:Dao.DaoResultado.java

public boolean registrarVarios(Session session, List<Resultado> resultados) throws Exception {
    for (Resultado r : resultados) {
        session.save(r);/*ww  w  .  j  a  v  a 2  s . c om*/
        session.flush();
        session.clear();
    }
    return true;
}

From source file:Dao.DaoResultado.java

public boolean actualizarVarios(Session session, List<Resultado> resultados) throws Exception {
    for (Resultado r : resultados) {
        session.update(r);/*from w  ww  .  j  a  va 2s  . com*/
        session.flush();
        session.clear();
    }
    return true;
}