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.ContaRepository.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<Conta> findAllAtivos() {
    Criteria criteria = getSession().createCriteria(Conta.class);
    criteria.add(Restrictions.eq("ativo", true));
    criteria.add(Restrictions.ne("tipoConta", TipoConta.CARTAO));
    return criteria.addOrder(Order.asc("descricao")).list();
}

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

License:Open Source License

@SuppressWarnings("unchecked")
public List<Conta> findByDescricaoAndUsuario(String descricao, Usuario usuario) {
    Criteria criteria = getSession().createCriteria(Conta.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  . ja  v a  2  s  . c  o  m
    criteria.add(Restrictions.ne("tipoConta", TipoConta.CARTAO));
    return criteria.addOrder(Order.asc("descricao")).list();
}

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

License:Open Source License

@SuppressWarnings("unchecked")
public List<Conta> findByBancoAndUsuario(Banco banco, Usuario usuario) {
    Criteria criteria = getSession().createCriteria(Conta.class);
    criteria.add(Restrictions.eq("banco.id", banco.getId()));
    criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    criteria.add(Restrictions.ne("tipoConta", TipoConta.CARTAO));
    return criteria.addOrder(Order.asc("descricao")).list();
}

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

License:Open Source License

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

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

License:Open Source License

@SuppressWarnings("unchecked")
public List<Conta> findEnabledByUsuario(Usuario usuario) {
    Criteria criteria = getSession().createCriteria(Conta.class);
    criteria.add(Restrictions.eq("ativo", true));
    criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    criteria.add(Restrictions.ne("tipoConta", TipoConta.CARTAO));
    return criteria.addOrder(Order.asc("descricao")).list();
}

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

License:Open Source License

@SuppressWarnings("unchecked")
public List<Conta> findOnlyTipoCartaoEnabledByUsuario(Usuario usuario) {
    Criteria criteria = getSession().createCriteria(Conta.class);
    criteria.add(Restrictions.eq("ativo", true));
    criteria.add(Restrictions.eq("usuario.id", usuario.getId()));
    criteria.add(Restrictions.eq("tipoConta", TipoConta.CARTAO));
    return criteria.addOrder(Order.asc("descricao")).list();
}

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

License:Open Source License

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

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

License:Open Source License

@SuppressWarnings("unchecked")
public List<Despensa> findByDescricaoAndUsuario(String descricao, Usuario usuario) {
    Criteria criteria = getSession().createCriteria(Despensa.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.DespensaRepository.java

License:Open Source License

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

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

License:Open Source License

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