Example usage for org.hibernate SessionFactory openSession

List of usage examples for org.hibernate SessionFactory openSession

Introduction

In this page you can find the example usage for org.hibernate SessionFactory openSession.

Prototype

Session openSession() throws HibernateException;

Source Link

Document

Open a Session .

Usage

From source file:ClasseDao.ItemvendaDao.java

public java.util.List listarItens() {
    try {/*from   w  w  w  . j  a v  a 2 s  .c o m*/
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        Session sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("from  ItemVenda").list();
        sessao.close();
        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao preencher tabela" + e);
    }
    return null;
}

From source file:ClasseDao.PagamentoDao.java

public java.util.List listarTodas() {
    try {//from w ww. j av a2 s.c  o  m
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("from  PagamentoEmprestimo").list();
        sessao.close();
        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao preencher tabela" + e);
    }
    return null;
}

From source file:ClasseDao.PerfilDao.java

public java.util.List listarTodos() {
    try {// ww  w  .j a v  a 2s  .c o m
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        Session sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("from  Perfil").list();
        sessao.close();
        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao preencher tabela" + e);
    }
    return null;
}

From source file:ClasseDao.PerfilDao.java

public java.util.List listarNomes() {
    try {//ww w . j ava  2s.co  m
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        Session sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("select perfilNome from Perfil ").list();
        sessao.close();

        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao buscar o nome do Produto" + e);
    }
    return null;
}

From source file:ClasseDao.ProdutoDao.java

public java.util.List listarTodos() {
    try {/*  w  w  w  . j a va 2s  .  com*/
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        Session sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("from  Produto").list();
        sessao.close();
        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao preencher tabela" + e);
    }
    return null;
}

From source file:ClasseDao.ProdutoDao.java

public java.util.List listarNomes() {
    try {/*from  w ww.  j a  v a  2s.c  om*/
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        Session sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("select nomeProduto from Produto ").list();
        sessao.close();

        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao buscar o nome do Produto" + e);
    }
    return null;
}

From source file:ClasseDao.RelatorioEntradaDao.java

public java.util.List listarTodos(Tipoproduto cli) {
    try {/*from   w w w . jav  a2  s .  co  m*/
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("from  RelatorioEntrada order by idRelatorioEntrada  ").list();
        sessao.close();
        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao preencher tabela" + e);
    }
    return null;
}

From source file:ClasseDao.UsuarioDao.java

public java.util.List listarTodos() {
    try {//from ww w . j  av a 2s  . co m
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("from  Usuario").list();
        sessao.close();
        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao preencher tabela" + e);
    }
    return null;
}

From source file:ClasseDao.UsuarioDao.java

public java.util.List listarNomes() {
    try {/*ww  w  . j a v a2s.c  om*/
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        Session sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("SELECT nomeUsuario from Usuario ").list();
        sessao.close();

        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao preencher tabela" + e);
    }
    return null;
}

From source file:ClasseDao.VendaDao.java

public java.util.List listarTodas() {
    try {//from w ww  .  j  a va 2 s .co  m
        SessionFactory tp = new Configuration().configure().buildSessionFactory();
        sessao = tp.openSession();
        java.util.List lista = new ArrayList();
        lista = sessao.createQuery("from  Venda").list();
        sessao.close();
        return lista;
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "Erro ao preencher tabela" + e);
    }
    return null;
}