Sorry... i was trying to be short and direct to the point... but... here goes the code...
Student POJO
Code:
public class Student {
private Integer id;
private Course course;
private String name;
}
Course POJO
Code:
public class Course {
private Integer id;
private String description;
}
TestDAO
Code:
Criteria c = SessionManager.getSession().createCriteria(Student.class);
c.createAlias("course", "course", CriteriaSpecification.LEFT_JOIN);
ProjectionList pl = Projections.projectionList();
pl.add(Projections.property("id"), "id");
pl.add(Projections.property("name"), "name");
pl.add(Projections.property("course.description"), "course.description");
c.setProjection(pl);
c.setResultTransformer(new AliasToBeanResultTransformer(Student.class));
Now... the point is, I want to bring just what I need, because in my real application I have a lot of fields (properties) in the POJOs (both of them)...
Thanks again!