Example usage for org.hibernate Criteria addOrder

List of usage examples for org.hibernate Criteria addOrder

Introduction

In this page you can find the example usage for org.hibernate Criteria addOrder.

Prototype

public Criteria addOrder(Order order);

Source Link

Document

Add an Order ordering to the result set.

Usage

From source file:br.com.hslife.orcamento.repository.AgendaRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Agenda> findByCriterioAgendamento(CriterioAgendamento criterioBusca) {
    Criteria criteria = getSession().createCriteria(Agenda.class);

    if (criterioBusca.getDescricao() != null && !criterioBusca.getDescricao().trim().isEmpty()) {
        criteria.add(Restrictions.ilike("descricao", criterioBusca.getDescricao(), MatchMode.ANYWHERE));
    }/*from www .  j a va  2 s.  c o m*/

    if (criterioBusca.getInicio() != null) {
        criteria.add(Restrictions.ge("inicio", criterioBusca.getInicio()));
    }

    if (criterioBusca.getFim() != null) {
        criteria.add(Restrictions.le("fim", criterioBusca.getFim()));
    }

    if (criterioBusca.getTipo() != null) {
        criteria.add(Restrictions.eq("tipoAgendamento", criterioBusca.getTipo()));
    }

    if (criterioBusca.getUsuario() != null) {
        criteria.add(Restrictions.eq("usuario.id", criterioBusca.getUsuario().getId()));
    }

    return criteria.addOrder(Order.asc("descricao")).list();
}

From source file:br.com.hslife.orcamento.repository.ArquivoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Arquivo> findByCriterioArquivo(CriterioArquivo criterio) {
    Criteria criteria = getSession().createCriteria(Arquivo.class);

    if (criterio.getNome() != null && !criterio.getNome().isEmpty()) {
        criteria.add(Restrictions.ilike("nomeArquivo", criterio.getNome(), MatchMode.ANYWHERE));
    }/*from w  w  w  .j  av a  2 s.  c  o m*/

    if (criterio.getInicio() != null) {
        criteria.add(Restrictions.ge("dataCriacao", criterio.getInicio()));
    }

    if (criterio.getFim() != null) {
        criteria.add(Restrictions.le("dataCriacao", criterio.getFim()));
    }

    if (criterio.getContainer() != null) {
        criteria.add(Restrictions.eq("container", criterio.getContainer()));
    }

    criteria.add(Restrictions.eq("usuario.id", criterio.getUsuario().getId()));

    return criteria.addOrder(Order.asc("nomeArquivo")).list();
}

From source file:br.com.hslife.orcamento.repository.AuditoriaRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Auditoria> findByCriteriosAuditoria(CriterioAuditoria criterio) {
    Criteria criteria = getSession().createCriteria(Auditoria.class);

    for (Criterion criterion : criterio.buildCriteria()) {
        criteria.add(criterion);//  w  ww . j  av a 2 s.c om
    }

    return criteria.addOrder(Order.asc("dataHora")).list();
}

From source file:br.com.hslife.orcamento.repository.BancoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Banco> findByNomeAndUsuario(String nome, Usuario usuario) {
    Criteria criteria = getSession().createCriteria(Banco.class);
    criteria.add(Restrictions.ilike("nome", nome, MatchMode.ANYWHERE));
    criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    return criteria.addOrder(Order.asc("nome")).list();
}

From source file:br.com.hslife.orcamento.repository.BancoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Banco> findByUsuario(Usuario usuario) {
    Criteria criteria = getSession().createCriteria(Banco.class);
    criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    return criteria.addOrder(Order.asc("nome")).list();
}

From source file:br.com.hslife.orcamento.repository.CartaoCreditoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<CartaoCredito> findByDescricaoAndUsuario(String descricao, Usuario usuario) {
    Criteria criteria = getSession().createCriteria(CartaoCredito.class);
    criteria.add(Restrictions.ilike("descricao", descricao, MatchMode.ANYWHERE));
    criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    return criteria.addOrder(Order.asc("descricao")).list();
}

From source file:br.com.hslife.orcamento.repository.CartaoCreditoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<CartaoCredito> findByUsuario(Usuario usuario) {
    Criteria criteria = getSession().createCriteria(CartaoCredito.class);
    criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    return criteria.addOrder(Order.asc("descricao")).list();
}

From source file:br.com.hslife.orcamento.repository.CartaoCreditoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<CartaoCredito> findOnlyCartaoTipoCreditoByUsuario(Usuario usuario) {
    Criteria criteria = getSession().createCriteria(CartaoCredito.class);
    criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    criteria.add(Restrictions.eq("tipoCartao", TipoCartao.CREDITO));
    criteria.add(Restrictions.isNull("cartaoSubstituto"));
    return criteria.addOrder(Order.asc("descricao")).list();
}

From source file:br.com.hslife.orcamento.repository.CartaoCreditoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<CartaoCredito> findEnabledOnlyCartaoTipoCreditoByUsuario(Usuario usuario) {
    Criteria criteria = getSession().createCriteria(CartaoCredito.class);
    criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    criteria.add(Restrictions.eq("tipoCartao", TipoCartao.CREDITO));
    criteria.add(Restrictions.eq("ativo", true));
    return criteria.addOrder(Order.asc("descricao")).list();
}

From source file:br.com.hslife.orcamento.repository.CategoriaDocumentoRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<CategoriaDocumento> findByDescricaoAndUsuario(String descricao, Usuario usuario) {
    Criteria criteria = getSession().createCriteria(CategoriaDocumento.class);
    criteria.add(Restrictions.ilike("descricao", descricao, MatchMode.ANYWHERE));
    if (!usuario.getLogin().equals("admin")) {
        criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    }/*from  w w  w  .jav  a  2  s.  c  om*/
    return criteria.addOrder(Order.asc("descricao")).list();
}