List of usage examples for org.hibernate Criteria addOrder
public Criteria addOrder(Order order);
From source file:br.com.muranodesign.dao.impl.MensagensDAOImpl.java
License:Creative Commons License
@Override @SuppressWarnings("unchecked") /*//ww w . j ava2 s. com * (non-Javadoc) * @see br.com.muranodesign.dao.MensagensDAO#listarProprietario(br.com.muranodesign.model.Usuario) */ public List<Mensagens> listarProprietario(Usuario proprietario) { Criteria criteria = getSession().createCriteria(Mensagens.class); criteria.addOrder(Order.asc("lida")); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idmensagens")); criteria.add(Restrictions.eq("proprietario", proprietario)); List<Mensagens> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.MensagensDAOImpl.java
License:Creative Commons License
@Override @SuppressWarnings("unchecked") /*//ww w. j a va 2 s. c om * (non-Javadoc) * @see br.com.muranodesign.dao.MensagensDAO#listarProprietario(br.com.muranodesign.model.Usuario, java.lang.String, int, int) */ public List<Mensagens> listarProprietario(Usuario proprietario, String caixa, int primeiro, int ultimo) { Criteria criteria = getSession().createCriteria(Mensagens.class); criteria.addOrder(Order.asc("lida")); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idmensagens")); if (caixa.equals("entrada")) { criteria.add(Restrictions.eq("cxEntrada", "S")); } else if (caixa.equals("enviado")) { criteria.add(Restrictions.eq("cxEnviada", "S")); } criteria.setFirstResult(primeiro); criteria.setMaxResults(ultimo); criteria.add(Restrictions.eq("proprietario", proprietario)); List<Mensagens> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.MensagensDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") /*//from w ww . ja va 2 s .co m * (non-Javadoc) * @see br.com.muranodesign.dao.MensagensDAO#listarProprietarioUnica(br.com.muranodesign.model.Usuario, java.lang.String) */ public List<Mensagens> listarProprietarioUnica(Usuario proprietario, String caixa) { Criteria criteria = getSession().createCriteria(Mensagens.class); if (caixa.equals("entrada")) { criteria.add(Restrictions.eq("cxEntrada", "S")); } else if (caixa.equals("enviado")) { criteria.add(Restrictions.eq("cxEnviada", "S")); } criteria.add(Restrictions.eq("proprietario", proprietario)); criteria.addOrder(Order.asc("lida")); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idmensagens")); List<Mensagens> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.MensagensDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Mensagens> listarMensagemByProprietario(int idProprietario, int idMensagem) { Criteria criteria = getSession().createCriteria(Mensagens.class); criteria.createAlias("proprietario", "proprietario"); criteria.add(Restrictions.eq("proprietario.idusuario", idProprietario)); criteria.add(Restrictions.eq("idmensagens", idMensagem)); criteria.addOrder(Order.asc("lida")); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idmensagens")); List<Mensagens> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.MensagensDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Mensagens> listarRemetente(int id) { Criteria criteria = getSession().createCriteria(Mensagens.class); criteria.createAlias("remetente", "remetente"); criteria.add(Restrictions.eq("remetente.idusuario", id)); criteria.addOrder(Order.asc("lida")); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idmensagens")); List<Mensagens> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.MensagensDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Mensagens> listarProprietario(int id) { Criteria criteria = getSession().createCriteria(Mensagens.class); criteria.createAlias("proprietario", "proprietario"); criteria.add(Restrictions.eq("proprietario.idusuario", id)); criteria.addOrder(Order.asc("lida")); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idmensagens")); List<Mensagens> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.MensagensDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Mensagens> listarProprietarioCount(int id) { Criteria criteria = getSession().createCriteria(Mensagens.class); criteria.createAlias("proprietario", "proprietario"); criteria.add(Restrictions.eq("proprietario.idusuario", id)); criteria.add(Restrictions.eq("lida", "N")); criteria.add(Restrictions.eq("cxEntrada", "S")); criteria.add(Restrictions.eq("cxEnviada", "N")); criteria.addOrder(Order.asc("lida")); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idmensagens")); List<Mensagens> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.ProducaoAlunoDAOImpl.java
License:Creative Commons License
@Override public List<ProducaoAluno> listaUltimasAluno(int idAluno) { Criteria criteria = getSession().createCriteria(ProducaoAluno.class); String ano = Integer.toString(Calendar.getInstance().get(Calendar.YEAR)); criteria.createAlias("anoLetivo", "anoLetivo"); criteria.add(Restrictions.eq("anoLetivo.ano", ano)); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", idAluno)); criteria.addOrder(Order.desc("data")); criteria.addOrder(Order.desc("idproducaoAluno")); criteria.setMaxResults(8);/*from w ww.ja va 2 s. c o m*/ List<ProducaoAluno> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.RoteiroDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Roteiro> listRoteiroRange(int primeiro, int ultimo) { Criteria criteria = getSession().createCriteria(Roteiro.class); ProjectionList projList = Projections.projectionList(); criteria.setFirstResult(primeiro);/*from w w w . j a v a 2 s . c o m*/ criteria.setMaxResults(ultimo); projList.add(Projections.property("idroteiro"), "idroteiro"); projList.add(Projections.property("nome"), "nome"); criteria.setProjection(projList).setCacheable(true); criteria.setResultTransformer(Transformers.aliasToBean(Roteiro.class)); criteria.addOrder(Order.asc("nome")); List<Roteiro> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.TutoriaDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Tutoria> listAll() { Criteria criteria = getSession().createCriteria(Tutoria.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.addOrder(Order.asc("tutoria")); List<Tutoria> result = criteria.list(); return result; }