List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
From source file:br.com.hslife.orcamento.repository.DocumentoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Documento> findByUsuario(Usuario usuario) { Criteria criteria = getSession().createCriteria(Documento.class, "documento") .createAlias("documento.categoriaDocumento", "categoria", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("categoria.usuario.id", usuario.getId())); return criteria.addOrder(Order.asc("documento.nome")).list(); }
From source file:br.com.hslife.orcamento.repository.DocumentoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Documento> findByCategoriaDocumento(CategoriaDocumento categoriaDocumento) { Criteria criteria = getSession().createCriteria(Documento.class); criteria.add(Restrictions.eq("categoriaDocumento.id", categoriaDocumento.getId())); return criteria.addOrder(Order.asc("nome")).list(); }
From source file:br.com.hslife.orcamento.repository.DocumentoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Documento> findByCategoriaDocumentoAndUsuario(CategoriaDocumento categoriaDocumento, Usuario usuario) {//from www .j av a 2 s . co m Criteria criteria = getSession().createCriteria(Documento.class, "documento") .createAlias("documento.categoriaDocumento", "categoria", JoinType.INNER_JOIN); criteria.add(Restrictions.eq("documento.categoriaDocumento.id", categoriaDocumento.getId())); criteria.add(Restrictions.eq("categoria.usuario.id", usuario.getId())); return criteria.addOrder(Order.asc("documento.nome")).list(); }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<FaturaCartao> findAllByCartaoCredito(Conta conta) { Criteria criteria = getSession().createCriteria(FaturaCartao.class); criteria.add(Restrictions.eq("conta.id", conta.getId())); return criteria.addOrder(Order.desc("dataVencimento")).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .list();/* w w w . ja v a 2 s . c om*/ }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<FaturaCartao> findAll() { Criteria criteria = getSession().createCriteria(FaturaCartao.class); return criteria.addOrder(Order.asc("dataVencimento")).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .list();//from ww w. jav a 2s . c o m }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
License:Open Source License
public FaturaCartao lastFaturaCartaoFechada(Conta conta) { StatusFaturaCartao status[] = { StatusFaturaCartao.ABERTA, StatusFaturaCartao.FUTURA }; Criteria criteria = getSession().createCriteria(FaturaCartao.class); criteria.add(Restrictions.eq("conta.id", conta.getId())); criteria.add(Restrictions.not(Restrictions.in("statusFaturaCartao", status))); return (FaturaCartao) criteria.addOrder(Order.desc("dataVencimento")) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).setMaxResults(1).uniqueResult(); }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
License:Open Source License
public FaturaCartao findFaturaCartaoAberta(Conta conta) { Criteria criteria = getSession().createCriteria(FaturaCartao.class); criteria.add(Restrictions.eq("conta.id", conta.getId())); criteria.add(Restrictions.eq("statusFaturaCartao", StatusFaturaCartao.ABERTA)); return (FaturaCartao) criteria.addOrder(Order.desc("dataVencimento")) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).uniqueResult(); }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public FaturaCartao findNextFaturaCartaoFutura(Conta conta) { Criteria criteria = getSession().createCriteria(FaturaCartao.class); criteria.add(Restrictions.eq("conta.id", conta.getId())); criteria.add(Restrictions.eq("statusFaturaCartao", StatusFaturaCartao.FUTURA)); List<FaturaCartao> resultado = criteria.addOrder(Order.asc("dataVencimento")) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); if (resultado != null && resultado.size() >= 1) { return resultado.get(0); }// w w w . j a v a2 s . c om return null; }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public FaturaCartao findNextFaturaCartaoFuturaByVencimento(Conta conta, Date dataVencimento) { Criteria criteria = getSession().createCriteria(FaturaCartao.class); criteria.add(Restrictions.eq("conta.id", conta.getId())); criteria.add(Restrictions.eq("dataVencimento", dataVencimento)); criteria.add(Restrictions.eq("statusFaturaCartao", StatusFaturaCartao.FUTURA)); List<FaturaCartao> resultado = criteria.addOrder(Order.asc("dataVencimento")) .setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list(); if (resultado != null && resultado.size() >= 1) { return resultado.get(0); }//from w w w . j a v a 2 s . c o m return null; }
From source file:br.com.hslife.orcamento.repository.FaturaCartaoRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<FaturaCartao> findByVencimentoAndStatusFatura(Conta conta, Date dataVencimento, StatusFaturaCartao status) {// ww w .j av a 2s . c o m Criteria criteria = getSession().createCriteria(FaturaCartao.class); criteria.add(Restrictions.eq("conta.id", conta.getId())); criteria.add(Restrictions.eq("dataVencimento", dataVencimento)); criteria.add(Restrictions.eq("statusFaturaCartao", status)); return criteria.addOrder(Order.asc("dataVencimento")).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY) .list(); }