List of usage examples for org.hibernate Criteria createAlias
public Criteria createAlias(String associationPath, String alias) throws HibernateException;
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; }
From source file:br.com.muranodesign.dao.impl.CalendarioEventosDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<CalendarioEventos> listarNotMural() { Criteria criteria = getSession().createCriteria(CalendarioEventos.class); criteria.createAlias("tipoEvento", "tipoEvento"); criteria.add(Restrictions.ne("tipoEvento.tipoEvento", "mural")); List<CalendarioEventos> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.ChamadaDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public long countFaltas(int id) { short t = 0;//from w ww . j a va 2 s. com Criteria criteria = getSession().createCriteria(Chamada.class); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_YEAR, 1); criteria.add(Restrictions.gt("data", cal.getTime())); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", id)); criteria.add(Restrictions.eq("presenca", t)); List<Chamada> result = criteria.list(); long r = result.size(); return r; }
From source file:br.com.muranodesign.dao.impl.ChamadaDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public long countPresencas(int id) { Criteria criteria = getSession().createCriteria(Chamada.class); Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_YEAR, 1); criteria.add(Restrictions.gt("data", cal.getTime())); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", id)); criteria.add(Restrictions.eq("presenca", (short) 1)); List<Chamada> result = criteria.list(); long r = result.size(); return r;//from w w w . j av a2 s. c o m }
From source file:br.com.muranodesign.dao.impl.ChamadaDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Chamada> dataPresenca(int id, Date data) { Criteria criteria = getSession().createCriteria(Chamada.class); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", id)); criteria.add(Restrictions.eq("data", data)); List<Chamada> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.ChamadaDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Chamada> dataPresencaAtual(int id, Date data) { Criteria criteria = getSession().createCriteria(Chamada.class); ProjectionList projList = Projections.projectionList(); projList.add(Projections.property("presenca"), "presenca"); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", id)); criteria.add(Restrictions.eq("data", data)); criteria.setProjection(projList).setCacheable(true); criteria.setResultTransformer(Transformers.aliasToBean(Chamada.class)); List<Chamada> 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.ChamadaDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Chamada> dataPresenca(int id, Calendar cal) { Criteria criteria = getSession().createCriteria(Chamada.class); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", id)); criteria.add(Restrictions.eq("data", cal.getTime())); List<Chamada> result = criteria.list(); return result; }
From source file:br.com.muranodesign.dao.impl.ChamadaDAOImpl.java
License:Creative Commons License
@SuppressWarnings("unchecked") public List<Chamada> listBetween(int idAluno, Date startDate, Date endDate) { Criteria criteria = getSession().createCriteria(Chamada.class); criteria.add(Restrictions.between("data", startDate, endDate)); criteria.createAlias("aluno", "aluno"); criteria.add(Restrictions.eq("aluno.idAluno", idAluno)); return criteria.list(); }