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.EditalDAO.java

public static List<Edital> obterEditais() throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();/*from w w  w . j a  v  a2 s.c  om*/
    session.clear();
    List<Edital> editais = session.createCriteria(Edital.class).list();

    return editais;
}

From source file:dao.EditalDAO.java

public static List<Edital> obterEditalPorNome(String nomeEdital) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();/* ww w  . j ava  2 s  .  c  o m*/
    session.clear();
    List<Edital> editais = session.createQuery("from edital where nome like '%' +nomeEdital+'%'").list();

    return editais;
}

From source file:dao.EditalDAO.java

public static Edital obterEdital(int codigoEdital) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();/*from   ww  w . jav a  2  s  . co  m*/
    session.clear();
    Edital edital = (Edital) session.load(Edital.class, codigoEdital);

    return edital;

}

From source file:dao.EditalDAO.java

public static void gravar(Edital edital) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.save(edital);// ww  w . ja  va  2 s.  c om
    transaction.commit();

}

From source file:dao.EditalDAO.java

public static void editar(Edital edital) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.update(edital);//w w  w.  j  ava 2 s  . com
    transaction.commit();

}

From source file:dao.EditalDAO.java

public static void excluir(Edital edital) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.delete(edital);//w w  w .j av a2  s  . c  om
    transaction.commit();

}

From source file:dao.NucleoDAO.java

public static List<Nucleo> obterNucleos() throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();//from  w  w w  . ja  va2s.co  m
    session.clear();
    List<Nucleo> nucleos = session.createCriteria(Nucleo.class).list();

    return nucleos;
}

From source file:dao.NucleoDAO.java

public static List<Nucleo> obterNucleoPorNome(String nomeNucleo) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();/*from   ww w. j a v a2s .c  o  m*/
    session.clear();
    List<Nucleo> nucleos = session.createQuery("from nucleo where nome like '%' +nomeNucleo+'%'").list();

    return nucleos;
}

From source file:dao.NucleoDAO.java

public static Nucleo obterNucleo(int codigoNucleo) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();//w  ww  . ja v a  2  s.  c o  m
    session.clear();
    Nucleo nucleo = (Nucleo) session.load(Nucleo.class, codigoNucleo);

    return nucleo;

}

From source file:dao.NucleoDAO.java

public static void gravar(Nucleo nucleo) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.save(nucleo);/*from   w  w w  .j  a  v a2s . com*/
    transaction.commit();

}