views:

300

answers:

0

Hello,

I have the following class-mapping that contains multiple collections mapped as :

Code:

<class entity-name="tab_a" table="tab_a" lazy="true"
      schema="dbo" dynamic-update="false" dynamic-insert="false"
      select-before-update="false">
      <id name="tabid" type="string" column="`TABID`">
         <generator class="native" />
      </id>
      <property name="SYSTIMESTAMP" column="`SYSTIMESTAMP`" type="java.sql.Timestamp" />      
      <bag name="collectionA">
         <key column="DOCID" />
         <one-to-many entity-name="tab_coll_A" />
      </bag>
      <bag name="collectionB">
         <key column="DOCID" />
         <one-to-many entity-name="tab_coll_B" />
      </bag>
      <bag name="collectionC">
         <key column="DOCID" />
         <one-to-many entity-name="tab_coll_C" />
      </bag>   
   </class>

I intend to formulate a HQL query in order to load all these in single query. Using left join does not prevent from generation of separate selects to load each collection:

from tab_a d  
left join  d.collectionA  
left join   d.collectionB  
left join   d.collectionC
where (d.tabid =:id)

HIBERNATE OUTPUT:

Hibernate: /* from tab_a d  left join  d.collectionA  left join   d.collectionB  left join   d.collectionC  where (d.tabid =:id)  */ select ...
Hibernate: /* load one-to-many tab_a.SYSJCRVERSIONS */ select ....
Hibernate: /* load one-to-many tab_a.SYSBINPROPNAME */ select ....
Hibernate: /* load one-to-many tab_a.JCRXMIXINTYPES */ select ...

How to avoid these load one-to-many in HQL query? Is there any possibility to achive this?

Thank you in advance for your reply.

Regards