5 Replies Latest reply on May 23, 2005 10:22 PM by Mark Brazil

    Optimized loading.

    Christian Percy Newbie

      From what I read in the manual the "on_find" will load me all the matched records,
      which may be a lot or even to much,
      therefore there is the "on_load" which only loads the "page_size" specified number of records.
      But in all the examples the "on_find" also has the "<page_size>" tag so now I am lost.
      Is this tag superfluous in case of "on_find" or are there other differences.
      Is there a different meaning for "on_find" and "on_load" when specified by a ejbfindBy or ejbSelect, and in a relation?

      Where to specify the read ahead tags on 1..n relations in order to:
      Load the fields of the related entity bean when accessing the getter from the 1 side.
      Loading all the entities (and eventually some of there field data) when accessing the getter from the n side.
      What do I have to specify where?
      Here is an example which may (hopefully) clarify my question
      I used XDoclet tags and the resulting xml is at the end.


      In an Entity Bean (called Leaf) there is a method to retrieve the links from this Leaf
      /**
      *
      * @ejb.interface-method
      * view-type = "local"
      *
      * @ejb.relation
      * name = "fromLeaf-linkFroms"
      * role-name = "LeafLinkFromsRelationshipRole"
      *
      * @jboss.relation-read-ahead
      * strategy = "on-find"
      * eager-load-group = "allFields"
      */
      public abstract java.util.Collection getLinkFroms();


      The Link class the related to Leaf contains the corresponding method

      /**
      *
      * @ejb.interface-method
      * view-type = "local"
      *
      * @ejb.relation
      * name = "fromLeaf-linkFroms"
      * role-name = "LinkFromLeafRelationshipRole"
      *
      * @jboss.relation
      * fk-column = "FROMLEAF_PKLEAFID"
      * related-pk-field = "pkLeafId"
      *
      * @jboss.load-group
      * name = "allFields"
      *
      * @jboss.relation-read-ahead
      * strategy = "on-find"
      * page-size = "1000"
      * eager-load-group = "allFields"
      */
      public abstract com.ascom.opentas.as.element.internal.entitybeans.Leaf getFromLeaf();


      In my jbosscmp-jdbc.xml file the corresponding entry looks like


      <ejb-relation>
      <ejb-relation-name>fromLeaf-linkFroms</ejb-relation-name>

      <ejb-relationship-role>
      <ejb-relationship-role-name>LinkFromLeafRelationshipRole</ejb-relationship-role-name>
      <key-fields/>

      <read-ahead>
      on-find
      <page-size>1000</page-size>
      <eager-load-group>allFields</eager-load-group>
      </read-ahead>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>LeafLinkFromsRelationshipRole</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name>pkLeafId</field-name>
      <column-name>FROMLEAF_PKLEAFID</column-name>
      </key-field>
      </key-fields>

      <read-ahead>
      on-find
      <eager-load-group>allFields</eager-load-group>
      </read-ahead>
      </ejb-relationship-role>
      </ejb-relation>

      We currently are using jboss-3.2.6RC2 (with JRE 1.4.2_07) together with Oracle9i as DB

      Many many thanks for any help, information or suggestion to a person in distress.

      Percy Christian