HHH-7189: AliasToBeanResultTransformer: query accesses fields of another class

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<Employee> 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.