Hi!
In my application I have two business Objects, namely Product and Resource. A Product can have zero or more Resources, and Hibernate has field access to them, i.e.:
Code:
Product {
private Set _resources;
}
Resource {
}
I would like to retrieve every Resource belonging to a Product in HQL. Why do the following queries don 't work?
HSQL: select _resources from Product
By Hibernate converted to the following SQL:
select product0_.productCode as col_0_0_ from products product0_
HQL: select p._resources from Product as p
By Hibernate converted to the following SQL:
select . as col_0_0_ from products product0_, resources resource2_, productresources _resources1_ where product0_.productId=_resources1_.productId and _resources1_.resourceId=resource2_.resourceId
The first SQL query is valid SQL, but does not retrieve the Resources. The last SQL query is just invalid SQL.
Am I doing something wrong? Is this a bug in Hibernate?