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

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

}

From source file:dao.NucleoDAO.java

public static void excluir(Nucleo nucleo) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.delete(nucleo);// w w w. ja  v  a  2  s  . c  o m
    transaction.commit();

}

From source file:dao.OrientadorDAO.java

public static List<Orientador> obterOrientadores() throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();//from  ww w  .j a va  2  s.c o m
    session.clear();
    List<Orientador> orientadores = session.createCriteria(Orientador.class).list();

    return orientadores;
}

From source file:dao.OrientadorDAO.java

public static List<Orientador> obterOrientadorPorNome(String nomeOrientador)
        throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();/* w  ww .j ava2 s .c  o m*/
    session.clear();
    List<Orientador> orientadores = session
            .createQuery("from orientador where nome like '%' +nomeOrientador+'%'").list();

    return orientadores;
}

From source file:dao.OrientadorDAO.java

public static Orientador obterOrientador(int codigo) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();//from  w  w w.j a  v a  2s.  c  o m
    session.clear();
    // Orientador orientador = (Orientador) session.load(Orientador.class, matricula);

    List<Orientador> list = session.createCriteria(Orientador.class).list();
    for (int i = 0; i <= list.size() - 1; i++) {
        if (list.get(i).getMatricula() == codigo) {
            return (Orientador) list.get(i);
        }
    }

    return null;

}

From source file:dao.OrientadorDAO.java

public static void gravar(Orientador orientador) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.save(orientador.getPessoas());
    session.save(orientador);//w ww .j a va 2 s.c o  m
    transaction.commit();

}

From source file:dao.OrientadorDAO.java

public static void editar(Orientador orientador) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.update(orientador);//from  w  ww. j a v  a 2s  . c  o  m
    session.update(orientador.getPessoas());
    transaction.commit();

}

From source file:dao.OrientadorDAO.java

public static void excluir(Orientador orientador) throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    Transaction transaction = session.beginTransaction();
    session.clear();
    session.delete(orientador);//  w  w w.j a va 2  s . co  m
    session.delete(orientador.getPessoas());
    transaction.commit();

}

From source file:dao.SubAreaDAO.java

public static List<SubArea> obterSubAreas() throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();//from  w ww  .j  a  v  a 2  s  . c o  m
    session.clear();
    List<SubArea> subAreas = session.createCriteria(SubArea.class).list();

    return subAreas;
}

From source file:dao.SubAreaDAO.java

public static List<SubArea> obterSubAreaPorNome(String nomeSubArea)
        throws SQLException, ClassNotFoundException {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();//  w  w  w .j  ava 2 s .c om
    session.clear();
    List<SubArea> subAreas = session.createQuery("from subArea where nome like '%' +nomeSubArea+'%'").list();

    return subAreas;
}