List of usage examples for org.hibernate Query setLong
@Deprecated @SuppressWarnings("unchecked") default Query<R> setLong(String name, long val)
From source file:au.org.theark.lims.model.dao.BioCollectionDao.java
License:Open Source License
public BioCollection getBioCollectionByUID(final String biocollectionUid, final Long studyId, final String subjectUID) { String GET_BIO_COLLECTION_BY_UID_AND_STUDY_ID_AND_SUBJECTUID = "select bio from BioCollection as bio " + "left outer join bio.linkSubjectStudy as linkStudy " + "left outer join linkStudy.study as study " + "where bio.biocollectionUid = :biocollectionUid " + "and study.id = :studyId " + " and linkStudy.subjectUID = :subjectUID"; Query query = getSession().createQuery(GET_BIO_COLLECTION_BY_UID_AND_STUDY_ID_AND_SUBJECTUID); query.setString("biocollectionUid", biocollectionUid); query.setLong("studyId", studyId); query.setString("subjectUID", subjectUID); BioCollection bioCollection = (BioCollection) query.uniqueResult(); return bioCollection; }
From source file:br.com.hslife.imobiliaria.dao.impl.HibernateGenericDao.java
License:Open Source License
public List queryList(String namedQuery, Map<String, Object> params) { HibernateUtility.getSession().clear(); Query query = HibernateUtility.getSession().getNamedQuery(namedQuery); for (String key : params.keySet()) { if (params.get(key) instanceof String) { query.setString(key, (String) params.get(key)); }/*from w w w .j av a 2s .c o m*/ if (params.get(key) instanceof Long) { query.setLong(key, (Long) params.get(key)); } if (params.get(key) instanceof Integer) { query.setInteger(key, (Integer) params.get(key)); } if (params.get(key) instanceof Boolean) { query.setBoolean(key, (Boolean) params.get(key)); } if (params.get(key) instanceof Double) { query.setDouble(key, (Double) params.get(key)); } if (params.get(key) instanceof Date) { query.setDate(key, (Date) params.get(key)); } } return query.list(); }
From source file:br.com.hslife.imobiliaria.dao.impl.HibernateGenericDao.java
License:Open Source License
public void queryNoResult(String namedQuery, Map<String, Object> params) { Query query = HibernateUtility.getSession().getNamedQuery(namedQuery); for (String key : params.keySet()) { if (params.get(key) instanceof String) { query.setString(key, (String) params.get(key)); }/*from www . ja v a 2 s. c o m*/ if (params.get(key) instanceof Long) { query.setLong(key, (Long) params.get(key)); } if (params.get(key) instanceof Integer) { query.setInteger(key, (Integer) params.get(key)); } if (params.get(key) instanceof Boolean) { query.setBoolean(key, (Boolean) params.get(key)); } if (params.get(key) instanceof Double) { query.setDouble(key, (Double) params.get(key)); } if (params.get(key) instanceof Date) { query.setDate(key, (Date) params.get(key)); } } query.executeUpdate(); HibernateUtility.getSession().flush(); HibernateUtility.getSession().clear(); }
From source file:br.com.hslife.imobiliaria.dao.impl.HibernateGenericDao.java
License:Open Source License
public Object queryUnique(String namedQuery, Map<String, Object> params) { HibernateUtility.getSession().clear(); Query query = HibernateUtility.getSession().getNamedQuery(namedQuery); for (String key : params.keySet()) { if (params.get(key) instanceof String) { query.setString(key, (String) params.get(key)); }/*from w w w . j a v a2 s . c om*/ if (params.get(key) instanceof Long) { query.setLong(key, (Long) params.get(key)); } if (params.get(key) instanceof Integer) { query.setInteger(key, (Integer) params.get(key)); } if (params.get(key) instanceof Boolean) { query.setBoolean(key, (Boolean) params.get(key)); } if (params.get(key) instanceof Double) { query.setDouble(key, (Double) params.get(key)); } if (params.get(key) instanceof Date) { query.setDate(key, (Date) params.get(key)); } } return query.uniqueResult(); }
From source file:br.com.hslife.orcamento.repository.CartaoCreditoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<CartaoCredito> findDescricaoOrTipoCartaoOrAtivoByUsuario(String descricao, TipoCartao tipo, Usuario usuario, Boolean ativo) { StringBuilder hql = new StringBuilder(); hql.append("FROM CartaoCredito cartao WHERE "); if (descricao != null) { hql.append("cartao.descricao LIKE '%"); hql.append(descricao);/*from ww w . ja va2 s. c om*/ hql.append("%' AND "); } if (tipo != null) { hql.append("cartao.tipoCartao = :tipo AND "); } if (ativo != null) { hql.append("cartao.ativo = :ativo AND "); } hql.append("cartao.usuario.id = :idUsuario ORDER BY cartao.descricao ASC"); Query hqlQuery = getQuery(hql.toString()); if (tipo != null) { hqlQuery.setParameter("tipo", tipo); } if (ativo != null) { hqlQuery.setBoolean("ativo", ativo); } hqlQuery.setLong("idUsuario", usuario.getId()); return hqlQuery.list(); }
From source file:br.com.hslife.orcamento.repository.ContaRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Conta> findDescricaoOrTipoContaOrAtivoByUsuario(String descricao, TipoConta[] tipoConta, Usuario usuario, Boolean ativo) { StringBuilder hql = new StringBuilder(); hql.append("FROM Conta conta WHERE "); if (descricao != null) { hql.append("conta.descricao LIKE '%"); hql.append(descricao);//w w w . j ava 2 s . c o m hql.append("%' AND "); } if (tipoConta != null && tipoConta.length != 0) { hql.append("conta.tipoConta IN (:tipo) AND "); } if (ativo != null) { hql.append("conta.ativo = :ativo AND "); } hql.append("conta.usuario.id = :idUsuario ORDER BY conta.descricao ASC"); Query hqlQuery = getQuery(hql.toString()); if (tipoConta != null && tipoConta.length != 0) { hqlQuery.setParameterList("tipo", tipoConta); } if (ativo != null) { hqlQuery.setBoolean("ativo", ativo); } hqlQuery.setLong("idUsuario", usuario.getId()); return hqlQuery.list(); }
From source file:br.com.hslife.orcamento.repository.DividaTerceiroRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<DividaTerceiro> findFavorecidoOrTipoCategoriaOrStatusDividaByUsuario(Favorecido favorecido, TipoCategoria tipoCategoria, StatusDivida statusDivida, Usuario usuario) { StringBuilder hql = new StringBuilder(); hql.append("FROM DividaTerceiro divida WHERE "); if (favorecido != null) { hql.append("divida.favorecido.id = :idFavorecido AND "); }//ww w . j ava 2 s.com if (tipoCategoria != null) { hql.append("divida.tipoCategoria = :tipo AND "); } if (statusDivida != null) { hql.append("divida.statusDivida = :status AND "); } hql.append("divida.usuario.id = :idUsuario ORDER BY divida.dataNegociacao DESC"); Query hqlQuery = getQuery(hql.toString()); if (favorecido != null) { hqlQuery.setLong("idFavorecido", favorecido.getId()); } if (tipoCategoria != null) { hqlQuery.setParameter("tipo", tipoCategoria); } if (statusDivida != null) { hqlQuery.setParameter("status", statusDivida); } hqlQuery.setLong("idUsuario", usuario.getId()); return hqlQuery.list(); }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<FaturaCartao> findAllByUsuario(Usuario usuario) { String hql = "SELECT f FROM FaturaCartao f INNER JOIN f.conta c WHERE c.usuario.id = :idUsuario ORDER BY f.dataVencimento ASC"; Query query = getSession().createQuery(hql); query.setLong("idUsuario", usuario.getId()); return query.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); }
From source file:br.com.hslife.orcamento.repository.ItemDespensaRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ItemDespensa> findByDespensaUsuarioAndArquivado(Despensa despensa, Usuario usuario, boolean arquivado) { String hql = "select item from ItemDespensa as item inner join item.despensa as des where des.id = :idDespensa and des.usuario.id = :idUsuario and item.arquivado = :arquivado order by item.descricao asc"; Query query = getSession().createQuery(hql); query.setLong("idDespensa", despensa.getId()); query.setLong("idUsuario", usuario.getId()); query.setBoolean("arquivado", arquivado); return query.list(); }
From source file:br.com.hslife.orcamento.repository.ItemDespensaRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ItemDespensa> findByUsuarioAndArquivado(Usuario usuario, boolean arquivado) { String hql = "select item from ItemDespensa as item inner join item.despensa as des where des.usuario.id = :idUsuario and item.arquivado = :arquivado order by item.descricao asc"; Query query = getSession().createQuery(hql); query.setLong("idUsuario", usuario.getId()); query.setBoolean("arquivado", arquivado); return query.list(); }