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.RegistroDiarioDAOImpl.java

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<RegistroDiario> listaPlanoEstudoDara(int id, Date data) {
    Criteria criteria = getSession().createCriteria(RegistroDiario.class);
    criteria.createAlias("planoEstudo", "planoEstudo");
    criteria.add(Restrictions.eq("planoEstudo.idplanoEstudo", id));
    criteria.add(Restrictions.eq("data", data));
    List<RegistroDiario> result = criteria.list();
    return result;
}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<RelatorioTutoria> listarTutoriaAluno(int tutoria, int aluno) {
    Criteria criteria = getSession().createCriteria(RelatorioTutoria.class);
    criteria.createAlias("aluno", "aluno");
    criteria.add(Restrictions.eq("aluno.idAluno", aluno));
    criteria.createAlias("tutoria", "tutoria");
    criteria.add(Restrictions.eq("tutoria.idtutoria", tutoria));
    List<RelatorioTutoria> result = criteria.list();
    return result;
}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<RelatorioTutoria> listarTutoriaAlunoAno(int tutoria, int aluno, int ano) {
    Criteria criteria = getSession().createCriteria(RelatorioTutoria.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", aluno));
    criteria.createAlias("tutoria", "tutoria");
    criteria.add(Restrictions.eq("tutoria.idtutoria", tutoria));
    List<RelatorioTutoria> result = criteria.list();
    return result;
}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
@Override/*from w w w .ja v a 2s  .  c o  m*/
public List<RelatorioTutoria> getRelatorioData(Date inicio, Date fim, int idAluno) {
    Criteria criteria = getSession().createCriteria(RelatorioTutoria.class);
    criteria.add(Restrictions.between("data", inicio, fim));
    criteria.createAlias("aluno", "aluno");
    criteria.add(Restrictions.eq("aluno.idAluno", idAluno));
    List<RelatorioTutoria> result = criteria.list();
    return result;
}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Roteiro> listarAno(Integer i) {
    Criteria criteria = getSession().createCriteria(Roteiro.class);
    criteria.createAlias("anoEstudo", "anoEstudo");
    criteria.add(Restrictions.eq("anoEstudo.idanoEstudo", i));
    criteria.add(Restrictions.eq("ativo", 1));

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

}

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

License:Creative Commons License

@Override
@SuppressWarnings("unchecked")
public List<Roteiro> listarAnoEstudoLazy(int anoEstudo) {
    Criteria criteria = getSession().createCriteria(Roteiro.class);
    ProjectionList projList = Projections.projectionList();

    criteria.createAlias("anoEstudo", "anoEstudo");
    criteria.add(Restrictions.eq("anoEstudo.idanoEstudo", anoEstudo));
    criteria.add(Restrictions.eqOrIsNull("ativo", 1));
    projList.add(Projections.property("idroteiro"), "idroteiro");
    projList.add(Projections.property("nome"), "nome");
    criteria.setProjection(projList).setCacheable(true);
    criteria.setResultTransformer(Transformers.aliasToBean(Roteiro.class));
    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> listarProfessorId(int tutor, String ano) {
    Criteria criteria = getSession().createCriteria(Tutoria.class);
    criteria.createAlias("tutor", "tutor");
    criteria.add(Restrictions.eq("tutor.idprofessorFuncionario", tutor));
    criteria.createAlias("anoLetivo", "anoLetivo");
    criteria.add(Restrictions.eq("anoLetivo.ano", ano));
    List<Tutoria> result = criteria.list();
    return result;

}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Tutoria> listarProfessorId(int tutor) {
    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.createAlias("tutor", "tutor");
    criteria.add(Restrictions.eq("tutor.idprofessorFuncionario", tutor));
    List<Tutoria> result = criteria.list();
    return result;
}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Tutoria> listarAno(String ano) {
    Criteria criteria = getSession().createCriteria(Tutoria.class);
    criteria.createAlias("anoLetivo", "anoLetivo");
    criteria.add(Restrictions.eq("anoLetivo.ano", ano));
    criteria.addOrder(Order.asc("tutoria"));
    List<Tutoria> result = criteria.list();

    return result;

}

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

License:Creative Commons License

@SuppressWarnings("unchecked")
public List<Tutoria> listarAnoid(int id) {
    Criteria criteria = getSession().createCriteria(Tutoria.class);
    criteria.createAlias("anoLetivo", "anoLetivo");
    criteria.add(Restrictions.eq("anoLetivo.idanoLetivo", id));
    criteria.addOrder(Order.asc("tutoria"));
    List<Tutoria> result = criteria.list();

    return result;
}