List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
From source file:br.com.muranodesign.dao.impl.CalendarioDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Calendario> listFeriados(Calendar dataInicio, Calendar dataFim) { Criteria criteria = getSession().createCriteria(Calendario.class); criteria.add(Restrictions.or(Restrictions.ge("feriado", 1), Restrictions.eq("aula", 0))); criteria.add(Restrictions.eq("ano", dataInicio.get(Calendar.YEAR))); criteria.add(Restrictions.ge("dataInicio", dataInicio.getTime())); criteria.add(Restrictions.le("dataInicio", dataFim.getTime())); 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> listarFeriadosSemana(int dia, int mes) { Criteria criteria = getSession().createCriteria(Calendario.class); Calendar dataInicio = Calendar.getInstance(); dataInicio.set(Calendar.MONTH, mes); dataInicio.set(Calendar.DATE, dia); dataInicio.set(Calendar.WEEK_OF_MONTH, dataInicio.get(Calendar.WEEK_OF_MONTH)); dataInicio.set(Calendar.DAY_OF_WEEK, dataInicio.getFirstDayOfWeek()); Calendar dataFim = Calendar.getInstance(); dataFim.set(Calendar.MONTH, mes); dataFim.set(Calendar.DATE, dataInicio.get(Calendar.DATE) + 6); criteria.add(Restrictions.or(Restrictions.ge("feriado", 1), Restrictions.eq("aula", 0))); criteria.add(Restrictions.or(/* www. ja v a2 s .co m*/ (Restrictions.or(Restrictions.between("dataInicio", dataInicio.getTime(), dataFim.getTime()), Restrictions.between("dataFim", dataInicio.getTime(), dataFim.getTime()))), Restrictions.and(Restrictions.lt("dataInicio", dataInicio.getTime()), Restrictions.gt("dataFim", dataFim.getTime())))); criteria.addOrder(Order.asc("dataInicio")); List<Calendario> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.ChamadaDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Chamada> getFaltasSemana(int idAluno, int dia, int mes) { Criteria criteria = getSession().createCriteria(Chamada.class); Calendar primeiroDia = Calendar.getInstance(); primeiroDia.set(Calendar.MONTH, mes); primeiroDia.set(Calendar.DATE, dia); primeiroDia.set(Calendar.WEEK_OF_MONTH, primeiroDia.get(Calendar.WEEK_OF_MONTH)); primeiroDia.set(Calendar.DAY_OF_WEEK, primeiroDia.getFirstDayOfWeek()); Calendar ultimoDia = Calendar.getInstance(); ultimoDia.set(Calendar.MONTH, mes); ultimoDia.set(Calendar.DATE, primeiroDia.get(Calendar.DATE) + 6); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", idAluno)); //criteria.add(Restrictions.eq("presenca", (short)0)); criteria.add(Restrictions.ge("data", primeiroDia.getTime())); criteria.add(Restrictions.le("data", ultimoDia.getTime())); criteria.addOrder(Order.asc("data")); List<Chamada> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.ForumQuestaoDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<ForumQuestao> listAllOrder() { Criteria criteria = getSession().createCriteria(ForumQuestao.class); criteria.addOrder(Order.desc("data")); List<ForumQuestao> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.ForumQuestaoDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<ForumQuestao> topN(int qtd) { Criteria criteria = getSession().createCriteria(ForumQuestao.class); criteria.addOrder(Order.desc("idforumQuestao")); criteria.setMaxResults(qtd);/*from www.j av a2 s.com*/ List<ForumQuestao> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.ForumQuestaoDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<ForumQuestao> ListaLikeRoteiro(String letra) { Criteria criteria = getSession().createCriteria(ForumQuestao.class); criteria.createAlias("roteiro", "roteiro"); criteria.add(Restrictions.like("roteiro.nome", letra, MatchMode.START)); criteria.addOrder(Order.desc("data")); List<ForumQuestao> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.GrupoDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Grupo> listarUltimo(String ano, String periodo) { Criteria criteria = getSession().createCriteria(Grupo.class); criteria.add(Restrictions.eq("status", "0")); criteria.add(Restrictions.like("nomeGrupo", ano, MatchMode.START)); criteria.add(Restrictions.like("nomeGrupo", periodo, MatchMode.ANYWHERE)); criteria.addOrder(Order.desc("nomeGrupo")); criteria.setMaxResults(1);//w w w . j ava 2s . com List<Grupo> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.GrupoDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") /*//w ww . ja v a 2 s. c o m * (non-Javadoc) * @see br.com.muranodesign.dao.GrupoDAO#ListarUltimoCiclo(java.lang.String) */ public List<Grupo> ListarUltimoCiclo(String ciclo, String periodo) { Criteria criteria = getSession().createCriteria(Grupo.class); criteria.add(Restrictions.eq("ciclo", ciclo)); criteria.add(Restrictions.eq("status", "0")); criteria.add(Restrictions.like("nomeGrupo", periodo, MatchMode.ANYWHERE)); criteria.addOrder(Order.desc("idgrupo")); criteria.setMaxResults(1); List<Grupo> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.MensagensDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Mensagens> listAll() { Criteria criteria = getSession().createCriteria(Mensagens.class); List<Mensagens> result = criteria.list(); criteria.addOrder(Order.asc("lida")); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idmensagens")); return result; }
From source file:br.com.muranodesign.dao.impl.MensagensDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Mensagens> listIntervalo(int primeiro, int ultimo) { Criteria criteria = getSession().createCriteria(Mensagens.class); criteria.setFirstResult(primeiro);/*w ww . j a va 2 s . co m*/ criteria.setMaxResults(ultimo); criteria.addOrder(Order.asc("lida")); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idmensagens")); List<Mensagens> result = criteria.list(); return result; }