I have a theoretical solution to the bidirectional relationships  problem.
The fundamental problem is the recurrence of  get*Value() calls between
arbitrary beans.  This cycle can get  very complex, so you can't simply rely
on a solution that fixes  the problem between just two beans.

The solution is to maintain a simple database-like cache of the  constructed
value objects.  The cache can be a simple object,  such as a Map.  The Map
would be keyed by entity name to another  Map, that would then be keyed by
primary key to a value object.

When a get*Value() method is called for an entity bean, it will  first try
to retrieve its value object from the cache.  If not  present, the value
object will be created and stored in the  cache.  The value object will then
be returned.

The simplest means of creating and maintaining this cache would  be to add a
get*Value(Map) method for every existing get*Value()  method.  The
get*Value() method will simply instantiate the Map,  and delegate to
get*Value(Map).  The get*Value(Map) method will  then perform mostly the
same logic that is currently in  get*Value(), wrapped with the cache lookup.
However, it must  use the get*Value(Map) methods of other beans, rather than
the  cache-less versions.  After the whole graph of value objects is
created, the cache will simply go out of scope and be garbage  collected.

I have implemented only a naive version of this that passes  around a single
value object for each extension of the  value-object graph.  It works for
tree-like bidirectional  relational schemas, but not for the general case.
It also  requires a new get*Value(<ValueClass>) method for each direction
in the relationship, so it was much more complex than the  solution provided
above.  I hope to submit a patch with the good  solution soon.

Andrew Barkley


-------------------------------------------------------
This sf.net email is sponsored by: Jabber - The world's fastest growing 
real-time communications platform! Don't just IM. Build it in! 
http://www.jabber.com/osdn/xim
_______________________________________________
Xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to