-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Load multiple bags in single select query
PostPosted: Fri Feb 26, 2010 12:18 pm 
Newbie

Joined: Tue Oct 09, 2007 12:07 pm
Posts: 6
Hello,

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

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 <bag> in single query. Using left join does not prevent from generation a separate selects to load each collection:

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


HIBERNATE OUTPUT:

Code:
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
Larysa


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.