read-ahead can now contain left-join configurations.

<!ELEMENT read-ahead (strategy, page-size?, eager-load-group?, left-join*)>
<!ELEMENT left-join (left-join*)>
<!-- The CMR field name to LEFT JOIN. -->
<!ATTLIST left-join cmr-field CDATA  #REQUIRED>
<!-- The eager load group of the related entity. -->
<!ATTLIST left-join eager-load-group CDATA  #IMPLIED>

left-join works only for on-find queries and assumes that the database supports LEFT OUTER JOIN.

How it works.
Suppose, there is an Order with one Customer and many LineItem's, each LineItem has Product. We want Order's findByPrimaryKey to fetch on-find the order with load group basic, its Customer with load group contact-info, its line items with the default load group and products with short load-group. It will look like this:


<query>
   <query-method>
      <method-name>findByPrimaryKey</method-name>
      ...
   </query-method>
   <jboss-ql>
      <![CDATA[SELECT OBJECT(o) FROM Order AS o WHERE o.id = ?1]]>
   </jboss-ql>
   <read-ahead>
      <strategy>on-find</strategy>
      <eager-load-group>basic</eager-load-group>
      <left-join cmr-field="customer" eager-load-group="contact-info"/>
      <left-join cmr-field="lineItem">
         <left-join cmr-field="product" eager-load-group="short"/>
      </left-join>
   </read-ahead>
</query>

This read-ahead can be applied to findAll to fetch all this info for all the orders in one query.
All kind of relationships are supported: one-to-one, one-to-many, many-to-many.
Self and circular references are no problem.




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to