Adam,
 
Did you get a solution for this yet?
 
The problem you are having is the value object has an aggregate.  This would happen in either a compose or aggregate.  And since your object is self-referential, it seems like you are stuck if you want an aggregate on this field, all or nothing. 
 
The solution is to define multiple value objects for the bean.  I always define two.  One header from a typical class has these two lines:
 
 * @ejb:value-object name="GL_AccountLight" match="light" 
 * @ejb:value-object name="GL_AccountFull" match="*"
 
Then, each persistent field (but NOT relationships) get a tag of:
 
* @ejb:value-object match="light"
 
Then finally, you have to change your relation aggregate to return a xxxLight value.
 
What happens then is you will get the node and one parent object, but without the relation in the parent because the parent is a "light" object.  This "breaks the chain" in a recursive load into the value object.
 
I generally think this is important in general if you start using aggregates or composites in VO's.  In a highly normalized database with a lot of relations and aggregates, you inevitably end up loading way more data than you want unless you use such a technique.  This may be one of the reasons they are hard to use, it took me a few days to grasp.  But I could be a dim bulb, what do I know... :-)
 
HTH,
 
-b
-----Original Message-----
From: Adam [mailto:[EMAIL PROTECTED]
Sent: Friday, May 30, 2003 3:02 AM
To: [EMAIL PROTECTED]
Subject: [Xdoclet-user] defining self-referring / recursive CMR

I'm having an issue with defining a CMR on an object that has children/parents of itself
 
ie, table form:
 
 node_id(tsn),  node_name, parent_node_id (parent_tsn)
 
/**
    * @ejb.interface-method
    * @ejb.relation
    *   name="node-has-children"
    *   role-name="node"
    *   target-ejb="Unit"
    *   target-role-name="children"
    *
    * @jboss.target-relation
    *   related-pk-field="tsn"
    *   fk-column="parent_tsn"
    *
    * @ejb.relation
    *    name="node-has-children"
    *    role-name="children"
    *
     * @ejb.value-object
     *    aggregate="com.foo.UnitValue"
     *    aggregate-name="ChildNode"
     *    members="com.foo.UnitLocal"
     *    members-name="UnitValue"
     *    relation="external"
     *    type="Collection"
     */
 
  Is this the correct way to do this?  It works.. but it works too well.   Once it loads the children for the object, it continues to load the children for each of those children, and then the children of all of those children... until it runs out of data.
  
  Is the value object the problem?  I'm using aggregate rather than compose, as the objects aren't responsible for creating each other (this is a static table).
 
Is this a factor of the way I've defined my relationship, or an issue with CMR or my app server? (I'm using JBoss 3.0.6).  Is there a tag I can add to control the read depth?  I've tried using the read-ahead strategy tag, but that doesn't seem to do anything (even when I set it to "none").  
 
I'm sorry if this isn't the right place.. just checking all possibilities (I've posted on the java forums, too).
 
Thanks for all help!
 
 

Reply via email to