List of usage examples for org.hibernate Session getNamedQuery
org.hibernate.Query getNamedQuery(String queryName);
From source file:br.com.ln.hibernate.Postgress.java
public static LnCliente grabClienteCpf(String cpf) { Session session = null; Transaction tx = null;//w ww. j a v a 2 s. c o m LnCliente lnCliente = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCliente.findByCliStCpf"); query.setString("cliStCpf", cpf); 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.hibernate.Postgress.java
public static LnCliente grabClienteCnpj(String cnpj) { Session session = null; Transaction tx = null;/*w w w . ja v a 2 s . c om*/ LnCliente lnCliente = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCliente.findByCliStCnpj"); query.setString("cliStCnpj", cnpj); 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.hibernate.Postgress.java
public static LnCliente grabClienteNome(String nome) { Session session = null; Transaction tx = null;/*from w w w . ja va 2s . co m*/ LnCliente lnCliente = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCliente.findByCliStNome"); query.setString("cliStNome", nome); 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.hibernate.Postgress.java
public static List<LnTelefone> grabListTelefones(Integer cliInCodigo) { Session session = null; Transaction tx = null;/*from w ww. ja va 2 s .c o m*/ List<LnTelefone> listTelefones = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnTelefone.findByCliInCodigo"); query.setInteger("cliInCodigo", cliInCodigo); listTelefones = query.list(); } finally { if (session != null && session.isOpen()) { session.close(); } } return listTelefones; }
From source file:br.com.ln.hibernate.Postgress.java
public static List<LnCliente> grabListCliente(Character sTipo) { Session session = null; Transaction tx = null;/* w ww .ja v a 2s . co m*/ List<LnCliente> listCliente = null; try { session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName); tx = session.beginTransaction(); Query query = session.getNamedQuery("LnCliente.findByCliChTipo"); query.setCharacter("cliChTipo", sTipo); listCliente = query.list(); tx.commit(); } finally { if (session != null && session.isOpen()) { session.close(); } } return listCliente; }
From source file:br.com.mandado.dao.BairroDAO.java
/** * @return/*from w w w .j a v a 2 s . c o m*/ */ @SuppressWarnings("unchecked") public List<Bairro> listar() { Session sessao = HibernateUtil.getSessionFactory().openSession(); List<Bairro> bairros = null; try { Query consulta = sessao.getNamedQuery("Bairro.listar"); bairros = consulta.list(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return bairros; }
From source file:br.com.mandado.dao.BairroDAO.java
/** * @param codigo//from w w w.j a v a2 s. c o m * @return */ public Bairro buscarPorCodigo(Long codigo) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Bairro bairro = null; try { Query consulta = sessao.getNamedQuery("Bairro.buscarPorCodigo"); consulta.setLong("codigo", codigo); bairro = (Bairro) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return bairro; }
From source file:br.com.mandado.dao.MandadoDAO.java
/** * @return/*from w ww. j a v a 2 s .co m*/ */ @SuppressWarnings("unchecked") public List<Mandado> listar() { Session sessao = HibernateUtil.getSessionFactory().openSession(); List<Mandado> mandados = null; try { Query consulta = sessao.getNamedQuery("Mandado.listar"); mandados = consulta.list(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return mandados; }
From source file:br.com.mandado.dao.MandadoDAO.java
/** * @param codigo//w w w.j a v a2s .c o m * @return */ public Mandado buscarPorCodigo(Long codigo) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Mandado mandado = null; try { Query consulta = sessao.getNamedQuery("Mandado.buscarPorCodigo"); consulta.setLong("codigo", codigo); mandado = (Mandado) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return mandado; }
From source file:br.com.sigcopex.dao.CursoDAO.java
public List<Curso> listar() { Session sessao = HibernateUtil.getSessionFactory().openSession(); List<Curso> cursos = null; try {//from ww w . j a v a2s. c om Query consulta = sessao.getNamedQuery("Curso.listar"); cursos = consulta.list(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return cursos; }