Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.ipn.escom.ageinnn.alumno.service; import com.ipn.escom.ageinnn.alumno.model.Alumno; import com.ipn.escom.ageinnn.curso.model.Grupo; import com.ipn.escom.ageinnn.curso.model.Inscripcion; import com.ipn.escom.ageinnn.service.Service; import java.util.List; import org.hibernate.Session; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; /** * * @author Erick */ public class AlumnoServiceImpl { private Session session; @SuppressWarnings("unchecked") public List<Grupo> findAllByAlumno(Alumno alumno) { List<Grupo> grupoList; setSession(Service.getSessionFactory().getCurrentSession()); this.session.beginTransaction(); grupoList = session.createCriteria(Inscripcion.class).add(Restrictions.eq("alumnoId", alumno.getId())) .setProjection(Projections.property("grupo")).list(); session.getTransaction().commit(); return grupoList; } public Session getSession() { return session; } public void setSession(Session session) { this.session = session; } }