hibernate/hibernate-orm — pull request #290 by orlandobcrra (2012-03-19 01:56:25+00:00)
Title: The problem arises when you want to transform the query result to an obj...

...ect when the query accesses fields of another class.

So here we present a simple and clean solution to build the object including nested fields.

Sample:

List list =
s.createQuery(""
+ "SELECT E.name as name, E.deparment.name as deparment_name "
+ "FROM "
+ Employee.class.getName()).
setResultTransformer(new AliasToBeanResultTransformer(Employee.class)).
list();

Where the departmet is a field of Employee class and we only want retrieve the department's name.

att:
Oracle Certified Master Java Developers: Orlando Becerra, Luis Gonzalez and Nelson Moncada.