Hibernate version: 3.2.4ga (HSQLDialect)
I'm using native SQL queries and they are not behaving as I expect them to. In particular addJoin() (in Java) or <return-join/> (in XML named query) don't do what I want them to do and in fact don't act any differently than addEntity.
I've been using the Hibernate supplied test case org.hibernate.test.sql.hand.query.NativeSQLQueriesTest.testSQLQueryInterface()
as provided in the release source code.
I can see no difference in the result of:
l = s.createSQLQuery( getOrgEmpPersonSQL() )
.addEntity("org", Organization.class)
.addJoin("emp", "org.employments")
.addJoin("pers", "emp.employee")
.list();
versus this:
l = s.createSQLQuery( getOrgEmpPersonSQL() )
.addEntity("org", Organization.class)
//.addJoin("emp", "org.employments")
//.addJoin("pers", "emp.employee")
.addEntity("emp", Employment.class)
.addEntity("pers", Person.class)
.list();
I expected the former to return a list of Organization objects and the latter to return a list of Object arrays, each containing 3 objects, Organization, Employment, and Person. However, in both cases I get the same result, which is a list of Object arrays as expected in the latter, and in both cases the org.employments and emp.employee have been filled in without further selects.
Is this a bug or is this the expected behavior? If this is not a bug, how can I get the query to return just a list of eagerly initialized Organization objects?
FYI, getOrgEmpPersonSQL() returns
Code:
select {org.*}, {emp.*}, {pers.*}
from ORGANIZATION org
join EMPLOYMENT emp on org.ORGID = emp.EMPLOYER
join PERSON pers on pers.PERID = emp.EMPLOYEE
Thanks,
=Jeremy=