Hello, I've read many posts and the documentation, but I cannot find a easy solution to an easy problem.
I have one class, for example BigFooObject, that collects many LittleDetail:
Code:
<class name="BigFooObject" table="big_foo_table"
<id name="uid" column="uid">
<generator class="assigned"/>
</id>
<property name="prop1" />
<set name="option" fetch="join" inverse="true">
<key column="bigfooref"/>
<one-to-many class="LittleDetail"/>
</set>
</class>
<class name="LittleDetail" table="little_detail_table" >
<id name="uid" column="uid">
<generator class="assigned"/>
</id>
<many-to-one name="bigfooref" class="BigFooObject"/>
</class>
Notice the fetch="join" in the set definition, I have the same question asked in this post without a real solution:
http://forum.hibernate.org/viewtopic.php?t=988028&postdays=0&postorder=asc&highlight=set+fetch+join&start=15It seems to me that Hibernate works in this way, for example retrieving BigFooObject #123:
Code:
select * from BigFooObject where uid = 123;
then redoes "select" to get all the information regarding LittleDetails found as reference in BigFooObject (do not tell me about lazy initialization,please, this is not the point):
Code:
select * from LittleDetail where uid = 3;
select * from LittleDetail where uid = 56;
select * from LittleDetail where uid = 129;
...
Is there a way to create a mapping that does something very simple like this
SINGLE query, having all the stuff correctly initialized in the appropriate pojos?
Code:
select bfo.*, ld.* from BigFooObject as bfo, LittleDetail as ld where bfo.uid = ld.bigfooref and bfo.uid = 123;
Thank you in advance.
Mirko