I've got 2 tables: Price and Product, each product has some prices:
Now I would like to fetch all prices and the corresponding products on a certain date.
So I create an eager-load-group in my price entity tag to load all data instead of just the rowid.
This works well,
But then I also need the info that's stored in the product, so JBoss starts to run a query for each price I loaded. I looked at the documentation I bought and found the chapter on Relationships lazy loading, so I added these linese to my jbosscmp-jdbc.xml:
<ejb-relation> <ejb-relation-name>ProductEJB - PriceEJB</ejb-relation-name> <ejb-relationship-role> <ejb-relationship-role-name>product</ejb-relationship-role-name> <key-fields> <key-field> <field-name>row_id</field-name> <column-name>product</column-name> </key-field> </key-fields> </ejb-relationship-role> <ejb-relationship-role> <ejb-relationship-role-name>price</ejb-relationship-role-name> <key-fields/> <read-ahead> <strategy>on-find</strategy> <page-size>4</page-size> <eager-load-group>allColumns</eager-load-group> </read-ahead> </ejb-relationship-role> </ejb-relation>