List of usage examples for org.hibernate Query setLong
@Deprecated @SuppressWarnings("unchecked") default Query<R> setLong(String name, long val)
From source file:br.com.hslife.orcamento.repository.ItemDespensaRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<ItemDespensa> findAllPerecivelByUsuario(Usuario usuario) { String hql = "select item from ItemDespensa as item inner join item.despensa as des where des.usuario.id = :idUsuario and item.perecivel = :perecivel and item.arquivado = :arquivado order by item.descricao asc"; Query query = getSession().createQuery(hql); query.setLong("idUsuario", usuario.getId()); query.setBoolean("perecivel", true); query.setBoolean("arquivado", false); return query.list(); }
From source file:br.com.hslife.orcamento.repository.LancamentoPeriodicoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<LancamentoPeriodico> findByTipoLancamentoContaAndStatusLancamento(TipoLancamentoPeriodico tipo, Conta conta, StatusLancamento statusLancamento) { StringBuilder hql = new StringBuilder(); hql.append("FROM LancamentoPeriodico periodico WHERE "); if (tipo != null) { hql.append("periodico.tipoLancamentoPeriodico = :tipo AND "); }// w ww.ja v a 2 s.co m if (conta != null) { hql.append("periodico.conta.id = :idConta AND "); } hql.append("periodico.statusLancamento = :status ORDER BY periodico.descricao ASC"); Query hqlQuery = getQuery(hql.toString()); if (tipo != null) { hqlQuery.setParameter("tipo", tipo); } if (conta != null) { hqlQuery.setLong("idConta", conta.getId()); } hqlQuery.setParameter("status", statusLancamento); return hqlQuery.list(); }
From source file:br.com.livraria.dao.AutorDAO.java
public Autor buscarPorCodigo(Long codigo) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Autor autor = null;/* ww w.j a v a2s . c o m*/ try { Query consulta = sessao.getNamedQuery("Autor.buscarPorCodigo"); consulta.setLong("codigo", codigo); autor = (Autor) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return autor; }
From source file:br.com.livraria.dao.FuncionarioDAO.java
public Funcionario buscarPorCodigo(Long codigo) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Funcionario funcionario = null;//from w ww . j av a2 s . c o m try { Query consulta = sessao.getNamedQuery("Funcionario.buscarPorCodigo"); consulta.setLong("codigo", codigo); funcionario = (Funcionario) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return funcionario; }
From source file:br.com.livraria.dao.ItemDAO.java
public Item buscarPorCodigo(Long codigo) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Item item = null;/*from ww w. jav a 2s . com*/ try { Query consulta = sessao.getNamedQuery("Item.buscarPorCodigo"); consulta.setLong("codigo", codigo); item = (Item) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return item; }
From source file:br.com.livraria.dao.VendaDAO.java
public Venda buscarPorCodigo(Long codigo) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Venda venda = null;//w w w . j a v a 2s .c om 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.mandado.dao.BairroDAO.java
/** * @param codigo//from w ww. 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
/** * @param codigo/*from w w w . j a v a 2 s . com*/ * @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 Curso buscarPorCodigo(Long codigo) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Curso curso = null;/*from w w w. j a v a 2 s. co m*/ try { Query consulta = sessao.getNamedQuery("Curso.buscarPorCodigo"); consulta.setLong("codigo", codigo); curso = (Curso) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return curso; }
From source file:br.com.sigcopex.dao.DisciplinaDAO.java
public Disciplina buscarPorCodigo(Long codigo) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Disciplina disciplina = null;/*from w ww . j a v a2 s. co m*/ try { Query consulta = sessao.getNamedQuery("Disciplina.buscarPorCodigo"); consulta.setLong("codigo", codigo); disciplina = (Disciplina) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return disciplina; }