List of usage examples for org.hibernate Query uniqueResult
R uniqueResult();
From source file:br.edu.ifes.sr.dw.persistencia.InstituicaoDaoHibernate.java
@Override public Instituicao validarLogin(String email, String senha) { session.getTransaction().begin();/*from w w w. j ava2 s. c o m*/ String hql = "select i from Instituicao i where i.email = :email and i.senha = :senha"; Query consulta = session.createQuery(hql); consulta.setString("email", email); consulta.setString("senha", senha); Instituicao instituicao = (Instituicao) consulta.uniqueResult(); session.getTransaction().commit(); session.close(); return instituicao; }
From source file:br.edu.ifes.sr.dw.persistencia.InstituicaoDaoHibernate.java
@Override public Instituicao buscar(String email) { session.getTransaction().begin();/* w w w.j a va2 s. c om*/ String hql = "select i from Instituicao i where i.email = :email"; Query consulta = session.createQuery(hql); consulta.setString("email", email); Instituicao instituicao = (Instituicao) consulta.uniqueResult(); session.getTransaction().commit(); session.close(); return instituicao; }
From source file:br.eti.sw.pontocerto.dao.impl.PontoDoDiaDAOHibernate.java
@Override public PontoDoDia buscarPontoDoDia(Date data, Usuario usuario) { String hql = "from PontoDoDia ponto where ponto.dataRealizacao = :data and ponto.usuario = :usuario"; Query consulta = this.session.createQuery(hql); consulta.setDate("data", data); consulta.setInteger("usuario", usuario.getId()); return (PontoDoDia) consulta.uniqueResult(); }
From source file:br.eti.sw.pontocerto.dao.impl.SalarioDAOHibernate.java
@Override public Salario buscarSalarioPorUsuario(Usuario usuario) { String hql = "from Salario salario where salario.usuario = :usuario"; Query consulta = this.session.createQuery(hql); consulta.setInteger("usuario", usuario.getId()); return (Salario) consulta.uniqueResult(); }
From source file:br.eti.sw.pontocerto.dao.impl.UsuarioDAOHibernate.java
@Override public Usuario buscarPorEmail(String email) { String hql = "from Usuario u where u.email = :email"; Query consulta = this.session.createQuery(hql); consulta.setString("email", email); return (Usuario) consulta.uniqueResult(); }
From source file:br.eti.sw.pontocerto.dao.impl.UsuarioDAOHibernate.java
@Override public Usuario buscarPorLogin(String login) { String hql = "from Usuario u where u.login = :login"; Query consulta = this.session.createQuery(hql); consulta.setString("login", login); return (Usuario) consulta.uniqueResult(); }
From source file:br.fgv.dao.ResultadosDAO.java
License:Open Source License
public String getCargoByID(String codCargo) { String ret = null;// w w w . j a v a2s. c o m try { QueryBuilder qb = new QueryBuilder(); qb.select_().coluna(CO_DIM_CARGO_DS)._from_().declareRef(TB_DIM_CARGO, a)._where_() .ref(CO_DIM_CARGO_CD, a)._eq_().valor(codCargo); Query query = getSession().createSQLQuery(qb.toString()); ret = (String) query.uniqueResult(); if (ret == null || ret.isEmpty()) { LOGGER.error("Nao pude obter cargo para id: " + codCargo); } } catch (RuntimeException e) { LOGGER.error("Exception ao tentar obter cargo para id: " + codCargo, e); } return ret; }
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
public int consultarQuantidade(final CpOrgaoDaoFiltro o) { try {//from www. ja v a 2 s.com final Query query = getSessao().getNamedQuery("consultarQuantidadeCpOrgao"); String s = o.getNome(); if (s != null) s = s.replace(' ', '%'); query.setString("nome", s); final int l = ((Long) query.uniqueResult()).intValue(); return l; } catch (final NullPointerException e) { return 0; } }
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
public int consultarQuantidade(final CpOrgaoUsuarioDaoFiltro o) { try {//from w ww . j a v a 2 s .c om final Query query = getSessao().getNamedQuery("consultarQuantidadeCpOrgao"); String s = o.getNome(); if (s != null) s = s.replace(' ', '%'); query.setString("nome", s); query.setCacheable(true); query.setCacheRegion(CACHE_QUERY_HOURS); final int l = ((Long) query.uniqueResult()).intValue(); return l; } catch (final NullPointerException e) { return 0; } }
From source file:br.gov.jfrj.siga.dp.dao.CpDao.java
License:Open Source License
public int consultarQuantidade(final DpCargoDaoFiltro o) { try {/* www . j a v a 2 s. co m*/ final Query query = getSessao().getNamedQuery("consultarQuantidadeDpCargo"); String s = o.getNome(); if (s != null) s = s.replace(' ', '%'); query.setString("nome", s); if (o.getIdOrgaoUsu() != null) query.setLong("idOrgaoUsu", o.getIdOrgaoUsu()); else query.setLong("idOrgaoUsu", 0); final int l = ((Long) query.uniqueResult()).intValue(); return l; } catch (final NullPointerException e) { return 0; } }