List of usage examples for org.hibernate Session getNamedQuery
org.hibernate.Query getNamedQuery(String queryName);
From source file:br.com.livraria.dao.VendaDAO.java
public List<Venda> listar() { Session sessao = HibernateUtil.getSessionFactory().openSession(); List<Venda> vendas = null; try {//from w w w . ja va 2s. co m Query consulta = sessao.getNamedQuery("Venda.listar"); vendas = consulta.list(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return vendas; }
From source file:br.com.livraria.dao.VendaDAO.java
public Venda buscarPorCodigo(Long codigo) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Venda venda = null;/*from w ww . ja v a 2s. co m*/ try { Query consulta = sessao.getNamedQuery("Venda.buscarPorCodigo"); consulta.setLong("codigo", codigo); venda = (Venda) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return venda; }
From source file:br.com.ln.dao.CategoriaDao.java
public static List<LnCategoria> grabCategoria(Character catChAtivo) { Session session = null; Transaction tx;//from w w w .ja v a 2s .c om List<LnCategoria> listCategoria = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCategoria.findByCatChAtivo"); query.setCharacter("catChAtivo", catChAtivo); listCategoria = query.list(); tx.commit(); } finally { if (session != null && session.isOpen()) { session.close(); } } return listCategoria; }
From source file:br.com.ln.dao.CategoriaDao.java
public static Integer grabTipoContaPorCategoria(Integer categoria) { Session session = null; Transaction tx;//from w w w . j ava2 s . c o m List<LnCategoria> listaCategoria = null; Integer tipInCodigo = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCategoria.findByCatInCodigo"); query.setInteger("catInCodigo", categoria); listaCategoria = query.list(); tx.commit(); tipInCodigo = listaCategoria.get(0).getTipInCodigo(); } finally { if (session != null && session.isOpen()) { session.close(); } } return tipInCodigo; }
From source file:br.com.ln.dao.CategoriaDao.java
public static List<LnCategoria> grabListaCategoria() { Session session = null; Transaction tx;/*ww w . j av a 2 s. c o m*/ List<LnCategoria> listaCategoria = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCategoria.findAll"); listaCategoria = query.list(); tx.commit(); } finally { if (session != null && session.isOpen()) { session.close(); } } return listaCategoria; }
From source file:br.com.ln.dao.CategoriaDao.java
public static LnCategoria grabCategoria(Integer idCategoria) { Session session = null; Transaction tx;/*from w ww . jav a 2 s . c o m*/ LnCategoria lnCategoria = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCategoria.findByCatInCodigo"); query.setInteger("catInCodigo", idCategoria); List list = query.list(); tx.commit(); if (list != null && list.size() > 0) { lnCategoria = (LnCategoria) list.get(0); } } finally { if (session != null && session.isOpen()) { session.close(); } } return lnCategoria; }
From source file:br.com.ln.dao.ClienteDao.java
public static LnCliente grabClienteCpf(String documento) { Session session = null; Transaction tx = null;//from www.j a v a 2s .c o m LnCliente lnCliente = null; try { session = SessionFactoryDbName.getCurrentSessionByName("acessocontrol"); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCliente.findByCliStDocumento"); query.setString("cliStDocumento", documento); List l = query.list(); tx.commit(); if (l != null && !l.isEmpty()) { lnCliente = (LnCliente) l.get(0); } } finally { if (session != null && session.isOpen()) { session.close(); } } return lnCliente; }
From source file:br.com.ln.dao.ClienteDao.java
public static LnCliente grabClienteCodigo(Integer cliInCodigo) { Session session = null; Transaction tx = null;//from ww w . j a v a 2 s .com LnCliente lnCliente = null; try { session = SessionFactoryDbName.getCurrentSessionByName("acessocontrol"); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCliente.findByCliInCodigo"); query.setInteger("cliInCodigo", cliInCodigo); List l = query.list(); tx.commit(); if (l != null && !l.isEmpty()) { lnCliente = (LnCliente) l.get(0); } } finally { if (session != null && session.isOpen()) { session.close(); } } return lnCliente; }
From source file:br.com.ln.dao.EnderecoDao.java
public static List<LnEndereco> grabListEnderecoCodigoCliente(Integer cliInCodigo) { Session session = null; Transaction tx = null;//from w ww. java 2s. c o m List<LnEndereco> listEndereco = null; try { session = SessionFactoryDbName.getCurrentSessionByName("acessocontrol"); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnEndereco.findByCliInCodigo"); query.setInteger("cliInCodigo", cliInCodigo); listEndereco = query.list(); tx.commit(); } finally { if (session != null && session.isOpen()) { session.close(); } } return listEndereco; }
From source file:br.com.ln.dao.FavorecidoDao.java
public static List<LnFavorecido> grabBancos() { Session session = null; Transaction tx;//from w ww.j av a 2s. c o m List<LnFavorecido> listaFavorecido = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnFavorecido.findByTfaInCodigo"); query.setInteger("tfaInCodigo", 2); listaFavorecido = query.list(); tx.commit(); } finally { if (session != null && session.isOpen()) { session.close(); } } return listaFavorecido; }