2 Replies Latest reply on Mar 14, 2002 12:05 PM by pazu

    Intersecting Load Groups

    pazu

      Hello, folks! (hello, Dain!)

      I was wondering if I'm able to define intersecting load groups in JBoss 3.0.0. Here is the scenario:

      I've a very large entity bean (+40 fields) and many Value Objects[1] defined for it. Each Value Object holds a different set of attributes for this entity. I've a minimal VO, two different intermediate VO's and a complete VO.

      Now, I want to define load-groups based on these VO's. The problem is: those load groups will be intersecting as one is a superset of the other.

      For example, the minimal load group needs description and reference. The intermediate load group needs type, price *and* the fields in the minimal load group.

      I've defined the following in jbosscmp-jdbc.xml:

      <load-groups>
       <load-group>
       <load-group-name>minimal</load-group-name>
       <field-name>description</load-group-name>
       <filed-name>reference</load-group-name>
       </load-group>
       <load-group>
       <load-group-name>intermediate</load-group-name>
       <field-name>type</field-name>
       <filed-name>price</field-name>
       </load-group>
       (...)
      </load-groups>
      

      Now, when I create a intermediate VO the CMP engine does one query to fetch the minimal load group and then another query to fetch the intermediate load group.[2]

      I want to make it do only one query for the intermediate load group. I can't include description and reference in the intermediate load group because that way when the minimal VO is instantiated, the intermediate load group will also be loaded.

      If this is not currently supported, here goes a feature request. One load group could be defined as depending on another group. Something like this:
      <load-group>
       <load-group-name>intermediate</load-group-name>
       <contained-load-groups>
       <load-group-name>minimal</load-group-name>
       </contained-load-groups>
       <field-name>type</field-name>
       <field-name>price</field-name>
      </load-group>
      

      That way, everytime type or price is hit, the container will load type, price, description and reference. When description or reference is hit, description and reference will be loaded.


      [1] Value Object is a concept from XDoclet. It's like a pumped up Data Objects, with the plus that they handle aggregation and composition, and you can define multiple VO's for each entity bean holding different attribute sets.

      [2] The real groups are much larger than this. I've simplified things for the sake of understanding.

        • 1. Re: Intersecting Load Groups
          dsundstrom

          A posting with footnotes :)

          Before I get going on the theory, you can have overlapping load groups. Now that I think about your problem, it would be very difficult to get everything setup properly.

          David and I have been having an offline discussion on the best way to specify the load groups and I think you really hit on the problem. The real goal of optimized loading is to load all of the data needed in a transaction using the least number of queries. right?

          That said we have several entry points into the transaction. JBossCMP uses the invocation of finders, ejbSelects, cmp-field getters, and cmr-field setters. Finders, ejbSelects and cmr-fields are individually configurable (i.e., they can be assigned a specific read-ahead strategy and load group).

          Everything else, including cmp-fields, use the default loading lazy load code. I think we really need to ability to specify a load group for every method. This way when you invoke a method, JBossCMP assures that all the fields in the load group are loaded before the method is invoked. Would this satisfy your needs?

          I like you idea of contained-load-groups, but as the 3.0 final release is quickly approaching, none this will be addressed until 3.1. The good thing is we have time to come up with the best solution.

          • 2. Re: Intersecting Load Groups
            pazu

            Configure load groups for every method may be nice, but I think this may lead to an overly complicated setup. I really like the idea of lazy load groups.

            Taking my scenario as an example, I could configure a load group for the intermediate VO getter and then the loading would be done in one query. However, if the default lazy loading strategy remains for the cmp-fields, I would have to also configure the CMP getters to the right load group. This may be too much configuration for a big entity. Let's make things efficient, but let's keep things simple.