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.muranodesign.dao.impl.AlunoVariavelDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<AlunoVariavel> ListarRangePeriodoSemGrupo(int idPeriodo, int primeiro, int ultimo) {
    Criteria criteria = getSession().createCriteria(AlunoVariavel.class);
    String ano = Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
    AnoLetivo anoLetivo = new AnoLetivoService().listarAnoLetivo(ano).get(0);
    criteria.add(Restrictions.eq("anoLetivo", anoLetivo));
    criteria.add(Restrictions.eq("ativo", 1));
    criteria.createAlias("periodo", "periodo");
    criteria.add(Restrictions.eq("periodo.idperiodo", idPeriodo));
    criteria.createAlias("grupo", "grupo", Criteria.LEFT_JOIN);
    criteria.add(Restrictions.or(Restrictions.isNull("grupo"), Restrictions.eq("grupo.status", "1")));
    criteria.createAlias("anoEstudo", "anoEstudo");
    criteria.addOrder(Order.asc("anoEstudo.ano"));
    criteria.createAlias("aluno", "aluno");
    criteria.addOrder(Order.asc("aluno.nome"));
    criteria.setFirstResult(primeiro);/*w  w w. jav a  2 s  .c o  m*/
    criteria.setMaxResults(ultimo);
    List<AlunoVariavel> result = criteria.list();
    return result;
}

From source file:br.com.muranodesign.dao.impl.AlunoVariavelDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
@Override//  w w w .j  a  v a  2  s .c  o m
public List<AlunoVariavel> listaTutoria(int id) {
    Criteria criteria = getSession().createCriteria(AlunoVariavel.class);
    criteria.createAlias("grupo", "grupo");
    criteria.createAlias("grupo.tutoria", "tutoria");
    criteria.add(Restrictions.eq("tutoria.idtutoria", id));
    String ano = Integer.toString(Calendar.getInstance().get(Calendar.YEAR));
    AnoLetivo anoLetivo = new AnoLetivoService().listarAnoLetivo(ano).get(0);
    criteria.add(Restrictions.eq("anoLetivo", anoLetivo));
    criteria.add(Restrictions.eq("ativo", 1));
    criteria.addOrder(Order.asc("grupo"));
    List<AlunoVariavel> result = criteria.list();
    return result;
}

From source file:br.com.muranodesign.dao.impl.AnoEstudoDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<AnoEstudo> listAll() {

    Criteria criteria = getSession().createCriteria(AnoEstudo.class);
    criteria.addOrder(Order.asc("ano"));
    List<AnoEstudo> result = criteria.list();

    return result;
}

From source file:br.com.muranodesign.dao.impl.CalendarioDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Calendario> listAll() {

    Criteria criteria = getSession().createCriteria(Calendario.class);
    criteria.addOrder(Order.asc("dataInicio"));
    List<Calendario> result = criteria.list();

    return result;
}

From source file:br.com.muranodesign.dao.impl.CalendarioDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Calendario> listVisivel() {
    Criteria criteria = getSession().createCriteria(Calendario.class);
    criteria.add(Restrictions.ge("visivel", 1));
    criteria.addOrder(Order.asc("dataInicio"));
    List<Calendario> result = criteria.list();

    return result;
}

From source file:br.com.muranodesign.dao.impl.CalendarioDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Calendario> listFiltroData(Date dataInicio, Date dataFim) {

    Criteria criteria = getSession().createCriteria(Calendario.class);
    criteria.add(Restrictions.ge("dataInicio", dataInicio));
    criteria.add(Restrictions.le("dataFim", dataFim));
    criteria.addOrder(Order.asc("dataInicio"));

    List<Calendario> result = criteria.list();

    return result;
}

From source file:br.com.muranodesign.dao.impl.CalendarioDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Calendario> listFeriados(int ano) {

    Criteria criteria = getSession().createCriteria(Calendario.class);

    criteria.add(Restrictions.or(Restrictions.ge("feriado", 1), Restrictions.eq("aula", 0)));
    criteria.add(Restrictions.eq("ano", ano));
    criteria.addOrder(Order.asc("dataInicio"));

    List<Calendario> result = criteria.list();

    return result;
}

From source file:br.com.muranodesign.dao.impl.CalendarioDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Calendario> listarKey(int key) {
    Criteria criteria = getSession().createCriteria(Calendario.class);
    criteria.add(Restrictions.eq("idcalendario", key));
    criteria.addOrder(Order.asc("dataInicio"));
    List<Calendario> result = criteria.list();
    return result;
}

From source file:br.com.muranodesign.dao.impl.CalendarioDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Calendario> listarEvento(int id) throws ParseException {

    Date data = Calendar.getInstance().getTime();

    Criteria criteria = getSession().createCriteria(Calendario.class);
    criteria.createAlias("tipoEvento", "tipoEvento");
    criteria.add(Restrictions.eq("tipoEvento.idtipoEvento", id));
    criteria.add(Restrictions.gt("dataInicio", data));
    criteria.addOrder(Order.asc("dataInicio"));
    List<Calendario> result = criteria.list();
    return result;
}

From source file:br.com.muranodesign.dao.impl.CalendarioDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Calendario> listarGeralMes(int mes, int ano) {
    Criteria criteria = getSession().createCriteria(Calendario.class);
    Calendar primeiroDia = Calendar.getInstance();
    primeiroDia.set(Calendar.YEAR, ano);
    primeiroDia.set(Calendar.MONTH, mes - 1);
    primeiroDia.set(Calendar.DAY_OF_MONTH, 1);
    Calendar ultimoDia = Calendar.getInstance();
    ultimoDia.set(Calendar.YEAR, ano);
    ultimoDia.set(Calendar.MONTH, mes - 1);
    ultimoDia.set(Calendar.DAY_OF_MONTH, ultimoDia.getActualMaximum(Calendar.DAY_OF_MONTH));
    criteria.createAlias("tipoEvento", "tipoEvento");
    criteria.add(Restrictions.eq("tipoEvento.idtipoEvento", 46));
    criteria.add(Restrictions.ge("dataInicio", primeiroDia.getTime()));
    criteria.add(Restrictions.le("dataInicio", ultimoDia.getTime()));
    criteria.addOrder(Order.asc("dataInicio"));
    List<Calendario> result = criteria.list();
    return result;
}