List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
From source file:br.com.financeiro.dao.LancamentoDAOHibernate.java
@Override public List<Lancamento> listar(Conta conta, Date dataInicio, Date dataFim) { Criteria criteria = this.session.createCriteria(Lancamento.class); if (dataInicio != null && dataFim != null) { criteria.add(Restrictions.between("data", dataInicio, dataFim)); } else if (dataInicio != null) { criteria.add(Restrictions.ge("data", dataInicio)); } else if (dataFim != null) { criteria.add(Restrictions.ge("data", dataFim)); }/*from w ww . j av a2 s . c o m*/ criteria.add(Restrictions.eq("conta", conta)); criteria.addOrder(Order.asc("data")); return criteria.list(); }
From source file:br.com.gartech.nfse.integrador.dao.GenericDAOImpl.java
@SuppressWarnings("unchecked") public List<T> findByExample(T entity, int firstResult, int maxResults) { Session session = getSession();/* w ww. jav a 2 s .c o m*/ log.debug("findByExample on " + getEntityClass()); Criteria criteria = session.createCriteria(getEntityClass()).add(Example.create(entity)); criteria.setFirstResult(firstResult); if (maxResults > 0) { criteria.setMaxResults(maxResults); criteria.addOrder(Order.asc("dataRecebimento")); } log.debug("findByExample result " + criteria.list().size()); return (List<T>) criteria.list(); }
From source file:br.com.gerenciapessoal.repository.Bancos.java
public List<Banco> filtrados(BancoFilter filter) { Session session = manager.unwrap(Session.class); Criteria criteria = session.createCriteria(Banco.class); if (StringUtils.isNotBlank(filter.getNumBanco())) { criteria.add(Restrictions.eq("numBanco", filter.getNumBanco())); }//from ww w . j a v a 2s .c o m if (StringUtils.isNotBlank(filter.getNome())) { criteria.add(Restrictions.ilike("nome", filter.getNome(), MatchMode.ANYWHERE)); } if (StringUtils.isNotBlank(filter.getUf())) { criteria.add(Restrictions.ilike("uf", filter.getUf(), MatchMode.ANYWHERE)); } if (StringUtils.isNotBlank(filter.getEstado())) { criteria.add(Restrictions.ilike("estado", filter.getEstado(), MatchMode.ANYWHERE)); } if (StringUtils.isNotBlank(filter.getEndereco())) { criteria.add(Restrictions.ilike("endereco", filter.getEndereco(), MatchMode.ANYWHERE)); } return criteria.addOrder(Order.asc("numBanco")).list(); }
From source file:br.com.gerenciapessoal.repository.Contas.java
public List<Conta> pesquisarConta(ContaFilter contaFilter) { Session session = this.manager.unwrap(Session.class); Criteria criteria = session.createCriteria(Conta.class).createAlias("banco", "b").createAlias("usuario", "u"); //Usuario u = manager.find(Usuario.class, s.getIdUsuario()); criteria.add(Restrictions.eq("u.id", s.getIdUsuario())); if (contaFilter.getBanco() != null) { criteria.add(Restrictions.eq("b.id", contaFilter.getBanco().getId())); }/*from ww w. j a v a2 s . c om*/ if (contaFilter.getAgencia() != null) { criteria.add(Restrictions.eq("agencia", contaFilter.getAgencia())); } if (contaFilter.getDvAgencia() != null) { criteria.add(Restrictions.eq("dvAgencia", contaFilter.getDvAgencia())); } if (contaFilter.getConta() != null) { criteria.add(Restrictions.eq("conta", contaFilter.getConta())); } if (contaFilter.getDvConta() != null) { criteria.add(Restrictions.eq("dvConta", contaFilter.getDvConta())); } if (contaFilter.getTipoConta() != null) { criteria.add(Restrictions.eq("tipoConta", contaFilter.getTipoConta())); } //return criteria.addOrder(Order.asc("id")).list(); return criteria.addOrder(Order.desc("id")).list(); }
From source file:br.com.gerenciapessoal.repository.Grupos.java
@SuppressWarnings("unchecked") public List<Grupo> todos() { Session session = manager.unwrap(Session.class); Criteria criteria = session.createCriteria(Grupo.class); // if (StringUtils.isNotBlank(filtro.getNome())) { // criteria.add(Restrictions.ilike("nome", filtro.getNome(), MatchMode.ANYWHERE)); // }//from w w w. j av a 2 s.c o m // // if (StringUtils.isNotBlank(filtro.getEmail())) { // criteria.add(Restrictions.ilike("email", filtro.getEmail(), MatchMode.ANYWHERE)); // } return criteria.addOrder(Order.asc("nome")).list(); }
From source file:br.com.gerenciapessoal.repository.Lancamentos.java
public List<Lancamento> lancamentoFiltrados(LancamentoFilter filterLanc) { Session session = manager.unwrap(Session.class); Criteria criteria = session.createCriteria(Lancamento.class).createAlias("conta", "c"); if (filterLanc.getConta() != null) { criteria.add(Restrictions.eq("c.id", filterLanc.getConta().getId())); if (filterLanc.getEmissaode() != null) { criteria.add(Restrictions.ge("dataEmissao", filterLanc.getEmissaode())); }//from w w w . j av a 2 s.c o m if (filterLanc.getEmissaoate() != null) { criteria.add(Restrictions.le("dataEmissao", filterLanc.getEmissaoate())); } } else { throw new NegocioException("Voc deve selecionar uma conta\n" + "antes de proceguir!"); } return criteria.addOrder(Order.asc("dataEmissao")).list(); }
From source file:br.com.gerenciapessoal.repository.Usuarios.java
@SuppressWarnings("unchecked") public List<Usuario> filtrados(UsuarioFilter filtro) { Session session = manager.unwrap(Session.class); Criteria criteria = session.createCriteria(Usuario.class); if (StringUtils.isNotBlank(filtro.getNome())) { criteria.add(Restrictions.ilike("nome", filtro.getNome(), MatchMode.ANYWHERE)); }//from www . j ava2s .c o m if (StringUtils.isNotBlank(filtro.getEmail())) { criteria.add(Restrictions.ilike("email", filtro.getEmail(), MatchMode.ANYWHERE)); } return criteria.addOrder(Order.asc("nome")).list(); }
From source file:br.com.hrstatus.dao.impl.ServersDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Servidores> listServers() { log.info("[ " + userInfo.getLoggedUsername() + " ] listServers()"); final Criteria criteria = session().createCriteria(Servidores.class); criteria.addOrder(Order.asc("hostname")); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); return criteria.list(); }
From source file:br.com.hslife.imobiliaria.dao.impl.AluguelDao.java
License:Open Source License
@SuppressWarnings("unchecked") @Override/*from ww w . j a v a 2 s . c o m*/ public List<Aluguel> listByNomeLocatarioOrContratoOrPeriodoOrAnoBeforeDataAndPago(String nomeLocatario, Long idContrato, Integer periodo, Integer ano, Date data, Boolean pago) { Criteria criteria = HibernateUtility.getSession().createCriteria(Aluguel.class, "aluguel") .createAlias("aluguel.contrato", "contrato").createAlias("contrato.locatario", "locatario"); if (nomeLocatario != null && !nomeLocatario.trim().isEmpty()) { criteria.add(Restrictions.ilike("locatario.nome", nomeLocatario, MatchMode.ANYWHERE)); } if (idContrato != null) { criteria.add(Restrictions.eq("contrato.id", idContrato)); } if (periodo != null) { criteria.add(Restrictions.eq("aluguel.periodo", periodo)); } if (ano != null) { criteria.add(Restrictions.eq("aluguel.ano", ano)); } if (data != null) { criteria.add(Restrictions.le("aluguel.vencimento", data)); } if (pago != null) { if (pago) { criteria.add(Restrictions.isNotNull("aluguel.pagamento")); } else { criteria.add(Restrictions.isNull("aluguel.pagamento")); } } criteria.addOrder(Order.asc("aluguel.vencimento")); return criteria.list(); }
From source file:br.com.hslife.orcamento.repository.AgendaRepository.java
License:Open Source License
@SuppressWarnings("unchecked") public List<Agenda> findByUsuario(Usuario usuario) { Criteria criteria = getSession().createCriteria(Agenda.class); criteria.add(Restrictions.eq("usuario.id", usuario.getId())); return criteria.addOrder(Order.asc("descricao")).list(); }