5 Replies Latest reply on Aug 21, 2003 2:54 AM by kv_moj

    JBoss 3.2.1 - How do I create an eager-load group with only

      Hi,

      Ok I know it's a bit of a strange question as the primary key is always eager-loaded.

      JBoss documentation states that when a query that selected the entity has defined an eager-load group, the eager-load fields are loaded as soon as a method is called on the entity. If there are any lazy-load groups, those fields will be loaded when a getter method of one of the group members is called.

      But what if the only field I require is the primary key. I would like to know if there's a way to configure an entity in such a way that if I only call the getter method of the primary key, no other fields are loaded.

      As it stands if I call the primary key getter without an eager-load definition, I see all the field of the row being loaded and if I try to create an eager-load group with just the primary key then I get a deployment exception.
      I think as JBoss does not allow the inclusion of the primary key field in the load-groups it should exclude the call to the primary key getter as a signal to load all the fields.

      kv.

        • 1. Re: JBoss 3.2.1 - How do I create an eager-load group with o
          raja05

          I have not done this but can you create a <read-ahead> group with the eager-load-group pointing to a single column in the table(other than the primary key).
          so it would be ssomething like

          <load-group>
          <load-group-name>ABC</load-group-name>
          <field-name>Field other than PK</field-name>
          </load-group>

          <eager-load-group>ABC</eager-load-group>

          <read-ahead>
          .....
          <eager-load-group>ABC</eager-load-group>
          </read-ahead>

          If you dont have a read-ahead group and you try to load the primary key, all the columns in the table would be loaded but if you do have a read-ahead with a single field, then only those would be loaded, which is closest to what you want.

          -Raj

          • 2. Re: JBoss 3.2.1 - How do I create an eager-load group with o

            Hi,

            Thanks for that.

            This is how I have it at the moment as it's the closest I can get to what I need.

            But I think this is an issue for JBoss dev to look at as there's little logic in loading all the fields when you call a getter for a field that's already loaded.

            kv.

            • 3. Re: JBoss 3.2.1 - How do I create an eager-load group with o
              raja05

              Heres a tweak.
              Change your JBossCMP DTD to be
              <!ELEMENT load-group (description?, load-group-name, field-name*)>

              instead of
              <!ELEMENT load-group (description?, load-group-name, field-name+)>
              (The * instead of + , so we can even have a load-group with no field-names in it)

              If this is the case, there would be no field-names to eager-load when the primary key is loaded.
              What do you think?

              -Raj

              • 4. Re: JBoss 3.2.1 - How do I create an eager-load group with o

                Good thinking,

                I've already tried this but without tweaking the DTD and of coarse got the validation errors.

                I'll try to see if Jboss'll accept an empty load-group after the XML's been parsed.

                kv.

                • 5. Re: JBoss 3.2.1 - How do I create an eager-load group with o

                  Yip,

                  Looks like that's done it.
                  JBoss will accept an empty load-group after tweaking the DTD.
                  Also I found that getPrimaryKey() can be called without JBoss loading any fields, but what I needed was this behavior on the primary key abstract getter and this seems to have done the trick.

                  Thanks for that.