Example usage for org.hibernate Criteria createAlias

List of usage examples for org.hibernate Criteria createAlias

Introduction

In this page you can find the example usage for org.hibernate Criteria createAlias.

Prototype

public Criteria createAlias(String associationPath, String alias) throws HibernateException;

Source Link

Document

Join an association, assigning an alias to the joined association.

Usage

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public long countFaltasAno(int idAluno, int ano) {
    short t = 0;/* w  ww.j a v a2  s. c om*/
    Criteria criteria = getSession().createCriteria(Chamada.class);
    Calendar calInicio = Calendar.getInstance();
    calInicio.set(Calendar.YEAR, ano);
    calInicio.set(Calendar.DAY_OF_YEAR, 1);
    Calendar calFim = Calendar.getInstance();
    calFim.set(Calendar.YEAR, ano);
    calFim.set(Calendar.DAY_OF_YEAR, calFim.getActualMaximum(Calendar.DAY_OF_YEAR));
    criteria.add(Restrictions.ge("data", calInicio.getTime()));
    criteria.add(Restrictions.le("data", calFim.getTime()));
    criteria.createAlias("aluno", "aluno");
    criteria.add(Restrictions.eq("aluno.idAluno", idAluno));
    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 List<Compensacao> compensacaoAluno(int idAluno) {
    Criteria criteria = getSession().createCriteria(Chamada.class);
    criteria.createAlias("aluno", "aluno");
    criteria.add(Restrictions.eq("aluno.idAluno", idAluno));
    criteria.add(Restrictions.isNotNull("compensacao"));
    criteria.setProjection(Projections.distinct(Projections.property("compensacao")));
    return criteria.list();
}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public long countCompensacao(Integer idAluno) {
    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", idAluno));
    criteria.add(Restrictions.eq("presenca", (short) 3));
    List<Chamada> result = criteria.list();
    long r = result.size();
    return r;//  www . jav a2  s. c  o  m
}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<ForumQuestao> listaRoteiro(int roteiro) {
    Criteria criteria = getSession().createCriteria(ForumQuestao.class);
    criteria.createAlias("roteiro", "roteiro");
    criteria.add(Restrictions.eq("roteiro.idroteiro", roteiro));
    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> listaUser(int idUser) {
    Criteria criteria = getSession().createCriteria(ForumQuestao.class);
    criteria.createAlias("usuario", "usuario");
    criteria.add(Restrictions.eq("usuario.idusuario", idUser));
    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.ForumRespostaDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public long Total(int id) {
    Criteria criteria = getSession().createCriteria(ForumResposta.class);
    criteria.createAlias("forumQuestao", "forumQuestao");
    criteria.add(Restrictions.eq("forumQuestao.idforumQuestao", id));
    List<ForumResposta> result = criteria.list();
    long r = result.size();
    return r;/*from   w w w .  j a v a 2 s .  c  o m*/

}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<ForumResposta> ListarTotal(int id) {
    Criteria criteria = getSession().createCriteria(ForumResposta.class);
    criteria.createAlias("forumQuestao", "forumQuestao");
    criteria.add(Restrictions.eq("forumQuestao.idforumQuestao", id));
    List<ForumResposta> result = criteria.list();
    return result;
}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<ForumResposta> ListaNVisto(int id) {
    Criteria criteria = getSession().createCriteria(ForumResposta.class);
    criteria.createAlias("forumQuestao", "forumQuestao");
    criteria.add(Restrictions.eq("forumQuestao.idforumQuestao", id));
    criteria.add(Restrictions.eq("visto", 0));

    List<ForumResposta> result = criteria.list();
    return result;

}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Grupo> listarTutoria(int tutor) {
    Criteria criteria = getSession().createCriteria(Grupo.class);
    criteria.add(Restrictions.eq("status", "0"));
    criteria.createAlias("tutoria", "tutoria");
    criteria.add(Restrictions.eq("tutoria.idtutoria", tutor));

    List<Grupo> result = criteria.list();
    return result;

}