Hi Andreas,

The best way that I found to solve this problem is to use two different value
objects for each entity, lets call them xxxLightValue and xxxFullValue.
http://xdoclet.sourceforge.net/valueobjects.html has the method by which to
create these in your class.  In the full object, you will use 'match="*"' and
in the light object let's say you use 'match="light"'.  So far, this
correlates to the link above.

I suspect you are currently only creating a full object.  Here is where we
are going to make some changes.  

If you do a compile at this point, you will have a xxxLightValue that has no
fields.  You need to go through and add '@ejb.value-object match="light"' to
all the fields you want in the light object.  But be careful to only add
objects to the light value that you want eager loaded.  

Next, when you define the aggregate or compose (again, see the above link),
you are going to specify that the aggregate or compose uses the appropriate
xxxLightValue.

In this manner, you now have two sets of VOs.  Full values containing
aggregations and/or compositions, and light values with just the field
values.  When you call entity.getLightValue(), you will end up with a value
that has no aggregates, just the entity fields.  Light values are not
terribly useful to grab from an entity, but I'm sure in some cases the
utility is there.  If you call entity.getFullValue(), the result has your
relations in it, but only to a depth of one level.  Because the a/c's return
light values that do not have other a/c's, you reach closure on the load. 

hope that helps,

-b

> -----Original Message-----
> From: Andreas Schildbach [mailto:[EMAIL PROTECTED]
> Sent: Monday, January 05, 2004 8:02 AM
> To: [EMAIL PROTECTED]
> Subject: [Xdoclet-user] EJB Value Objects and Lazy Loading
> 
> 
> Hello everyone,
> 
> XDoclet allows to map EJB relationships (e.g. CMR) to the 
> generated value objects. For example, XDoclet generates a 
> getter in one value object that retrieves the value object of 
> the related EJB in a 1-to-1 relationship.
> 
> Unfortunately, the code that initializes the first value 
> object also eager loads all related value objects. Is it 
> possible to change that behaviour to lazy loading? I want the 
> related EJB only loaded if one of the values is being used in 
> my business logic.
> 
> BTW, it does not help to configure the application server 
> (JBoss) to lazy loading (which is the default anyway), 
> because the value object init code actively retreives the 
> values of the related object.
> 
> Regards,
> 
> Andreas
> 
> 
> 
> ______________________________________________________________
> ________________
> Erdbeben im Iran: Zehntausende Kinder brauchen Hilfe. UNICEF hilft den
> Kindern - helfen Sie mit! https://www.unicef.de/spe/spe_03.php
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: IBM Linux Tutorials.
> Become an expert in LINUX or just sharpen your skills.  Sign 
> up for IBM's
> Free Linux Tutorials.  Learn everything from the bash shell 
> to sys admin.
> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
> _______________________________________________
> xdoclet-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-user
> 


-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to