2 Replies Latest reply on Sep 28, 2002 10:26 AM by humps

    eager loading with relationtable

    humps Newbie

      I'm trying to follow the example in the JBossCMP doc (the $10 pdf) regarding to optimised loading with CMR relationship.

      I'm trying to do a very simple read-ahead for a particular relationship mapped via a relationship table. Unfortunately, I can't add key fields when I use a <read-ahead>.... But I need both sides of the relationship-role populated for the relation-table!

      has anyone done that before?

      As a side comment to the excellent JBoss people, the JBoss CMP doc is good, but I wonder if detail coverage of optimised loading would be useful for people with lots of relationships and not so much findBy method? Because in an ideal OO world, you would walk your object trees rather than doing a lot of findBy (which is more like doing raw sql).

      many thanks

      humps

        • 1. Re: eager loading with relationtable
          Dain Sundstrom Master

          > I'm trying to do a very simple read-ahead for a
          > particular relationship mapped via a relationship
          > table. Unfortunately, I can't add key fields when I
          > use a <read-ahead>.... But I need both sides of the
          > relationship-role populated for the relation-table!
          >
          > has anyone done that before?

          You lost me. You can eagerload a multivalued field (cmr), but you can lazy load across the relationship. I personally consider this a design flaw, and I plan on fixing it in 4.0.

          > As a side comment to the excellent JBoss people, the
          > JBoss CMP doc is good, but I wonder if detail
          > coverage of optimised loading would be useful for
          > people with lots of relationships and not so much
          > findBy method? Because in an ideal OO world, you
          > would walk your object trees rather than doing a lot
          > of findBy (which is more like doing raw sql).

          Yes in an ideal 00 world you would walt the tree, but we live in a relational world. This means the optimal way to deal with relationships is to execute a query that "jumps" to the desired data. Remember that at the end of the day your are dealing with an array of bytes on a disk.

          • 2. Re: eager loading with relationtable
            humps Newbie

            First, thanks for your reply!
            What I really wanted to know is the actual jboss cmp xml. I got a SAXException saying I can't have <key-fields> when I have <read-ahead>. Which makes sense because the load group will tell the cmp which one is being mapped, but not so in a relation-table *-* relationship!
            The relation table itself is not being mapped as a bean, hence hasn't got a schemaName to reference while writting the JBossQL.
            So really, I couldn't work out how to eager-load or lazy-load a (*-*) CMR by reading the documentation. Wondering if anyone can shed some light :) Thanks again!

            Oh, and your comment about OO is spot on! Keep it real!