List of usage examples for org.hibernate Query setInteger
@Deprecated @SuppressWarnings("unchecked") default Query<R> setInteger(String name, int val)
From source file:br.com.sicva.dao.FoneDao.java
public Fone PesquisarFone(Integer id) { try {//from w w w . j a v a 2 s . co m session = new FabricaDeConexao().getSessionFactory().openSession(); Query query = session.createSQLQuery("select * from fone where FONE_PAC_ID = :id") .addEntity(Fone.class); query.setInteger("id", id); listarFone = query.list(); session.close(); if (listarFone.isEmpty()) { return null; } else { return listarFone.get(0); } } catch (Exception e) { System.out.println("" + e.getCause().getMessage()); return null; } }
From source file:br.com.sicva.dao.ItensVacinasDao.java
public List<ItensVacinas> listarItensVacinaPorPacientes(int codigo) { session = new HibernateUtil().getSessionFactory().openSession(); Query query = session.createSQLQuery("SELECT * FROM itens_vacinas inner join registros_vacinas\n" + "on Registros_id = ITENS_VACINAS_CARTEIRA_ID inner join vacinas\n" + "on ITENS_VACINAS_VACINAS_CODIGO = VACINAS_CODIGO inner join pacientes\n" + "on PACIENTES_NUMERO_REGISTRO_NASCIMENTO = REGISTROS_PACIENTES_NUMERO_REGISTRO_NASCIMENTO\n" + "WHERE PACIENTES_NUMERO_REGISTRO_NASCIMENTO = :codigo ").addEntity(ItensVacinas.class); query.setInteger("codigo", codigo); listarItensVacina = query.list();/*from w w w. j a v a2 s . co m*/ for (ItensVacinas it : listarItensVacina) { Hibernate.initialize(it.getVacinas()); Hibernate.initialize(it.getRegistrosVacinas()); } session.close(); if (listarItensVacina.isEmpty()) { return null; } else { return listarItensVacina; } }
From source file:br.com.sicva.dao.PacientesDao.java
public Pacientes listarPorRegistro(int codigo) { try {/*from www .ja v a 2s. c om*/ session = new HibernateUtil().getSessionFactory().openSession(); Query query = session .createSQLQuery( "select * from pacientes where PACIENTES_NUMERO_REGISTRO_NASCIMENTO = :registro") .addEntity(Pacientes.class); query.setInteger("registro", codigo); listarPacientes = query.list(); session.close(); return listarPacientes.get(0); } catch (Exception e) { return null; } }
From source file:br.com.sicva.dao.RegistroVacinaDao.java
public RegistrosVacinas PesquisarRegistroPorPacientes(int codigo) { session = new HibernateUtil().getSessionFactory().openSession(); Query query = session .createSQLQuery("SELECT * FROM registros_vacinas inner join pacientes on\n" + "PACIENTES_NUMERO_REGISTRO_NASCIMENTO = REGISTROS_PACIENTES_NUMERO_REGISTRO_NASCIMENTO\n" + "where PACIENTES_NUMERO_REGISTRO_NASCIMENTO = :codigo ") .addEntity(RegistrosVacinas.class); query.setInteger("codigo", codigo); listarItensVacina = query.list();/*from w w w . ja v a2 s . co m*/ session.close(); if (listarItensVacina.isEmpty()) { return null; } else { return listarItensVacina.get(0); } }
From source file:br.com.sicva.dao.UbsDao.java
public Ubs pesquisarPorId(Integer value) { try {//ww w.ja va2s. c o m session = new FabricaDeConexao().getSessionFactory().openSession(); Query query = session.createSQLQuery("select * from ubs where UBS_ID = :id").addEntity(Ubs.class); query.setInteger("id", value); listaUbs = query.list(); session.close(); if (listaUbs.isEmpty()) { return null; } else { return listaUbs.get(0); } } catch (Exception e) { System.out.println("" + e.getCause().getMessage()); return null; } }
From source file:br.com.sicva.dao.UbsDao.java
public List<Ubs> ListarPorZona(Integer value) { try {/* ww w .ja v a2 s. co m*/ session = new FabricaDeConexao().getSessionFactory().openSession(); Query query = session .createSQLQuery( "SELECT * FROM ubs\n" + "inner join\n" + " endereco on UBS_ENDERECO_ID = END_ID\n" + "inner join\n" + " bairro on END_BAIRRO_ID = BAIRRO_ID\n" + "inner join zona on ZONA_ID = BAIRRO_ZONA_ID\n" + "where ZONA_ID = :zona") .addEntity(Ubs.class); query.setInteger("zona", value); listaUbs = query.list(); for (Ubs u : listaUbs) { Hibernate.initialize(u.getEndereco()); Hibernate.initialize(u.getEndereco().getBairro()); } session.close(); if (listaUbs.isEmpty()) { return null; } else { return listaUbs; } } catch (Exception e) { System.out.println("" + e.getCause().getMessage()); return null; } }
From source file:br.com.sicva.dao.VacinacaoDao.java
public Integer QtdVacinacao(Integer vac_id, Integer pac_id) { session = new FabricaDeConexao().getSessionFactory().openSession(); Query query = session.createSQLQuery("select count(*) from vacinacao where vacinacao_vacina_id" + " = :vac_id and VACINACAO_PAC_ID = :pac_id"); query.setInteger("vac_id", vac_id); query.setInteger("pac_id", pac_id); Integer total = ((BigInteger) query.uniqueResult()).intValue(); session.close();//w w w .ja va 2 s.co m return total; }
From source file:br.com.sicva.dao.VacinaDao.java
public Vacina listarPorId(int codigo) { try {/*ww w.j a v a2 s. c om*/ session = new FabricaDeConexao().getSessionFactory().openSession(); Query query = session.createSQLQuery("select * from vacina where vacina_id = :id") .addEntity(Vacina.class); query.setInteger("id", codigo); listaVacina = query.list(); session.close(); return listaVacina.get(0); } catch (Exception e) { return null; } }
From source file:br.com.sicva.dao.VacinasDao.java
public Vacinas listarPorId(int codigo) { try {/*from w ww . j av a2 s .c o m*/ session = new HibernateUtil().getSessionFactory().openSession(); Query query = session.createSQLQuery("select * from vacinas where vacinas_id = :registro") .addEntity(Vacinas.class); query.setInteger("registro", codigo); listarVacinas = query.list(); session.close(); return listarVacinas.get(0); } catch (Exception e) { return null; } }
From source file:br.eti.sw.pontocerto.dao.impl.PontoDoDiaDAOHibernate.java
@Override public List<PontoDoDia> listar(Usuario usuario) { String hql = "from PontoDoDia ponto where ponto.usuario = :usuario ORDER BY ponto.dataRealizacao DESC"; Query consulta = this.session.createQuery(hql); consulta.setInteger("usuario", usuario.getId()); return consulta.list(); }