I'm trying to figure out exactly how to use the CMR functionality of the
ValueObjects. I think I have it working, but it's only by pure luck, and
not by an understanding of what I'm doing.
I am using 1.2b2.
The document entitled "Using Value Objects" references some method-level
tags for CMR composition in the @ejb.value-object which don't appear in the
documentation itself. While the document is a good start, I think it
confused me more than it helped (due to typos and not seeing snippets of the
relevant code of related items or the generated code)
I have 2 objects: User and UserProfile.
In the User object:
* @ejb.relation
* name="user-profile"
* role-name="user-has-profile"
* @ejb.value-object
* compose="user.interfaces.UserProfileValue"
* compose-name="Profile"
* members="user.interfaces.UserProfileLocal"
* members-name="Profile"
* relation="external"
*/
public abstract UserProfileLocal getProfile();
My understanding is this:
1. Use Composition when the Child is generally created by the Parent. In
this case, the profile would be created by/with the user.
Use aggregation when the Child can exist on its own without the
Parent. Ie, a Color item could stand on its own, even if referenced
somewhere as FavColor.
2. in the @ejb.value-object tag:
a. compose/aggregate: What type(s) of **ValueObject** items, in full
package form, is/are being contained in this bean field for this object's
**ValueObject**.
In the example above, a "profile" field contains a UserProfileLocal (local
because CMR fields must all be local references). In the resultant
**ValueObject** for the User, the "profile" field should contain a
UserProfileValue object.
b. compose-name/aggregate-name: What method, without the 'get'
portion, references the value object contained in the compose/aggregate
parameter.
QUESTION: Will this method be generated, or is it expected the method will
already exist?
ie, without using the composition params of the @ejb.value-object at the
method level, I presume that the ValueObject generation routines will
already create a get/setProfile() in the resulting ValueObject. So, should
the value I use for compose-name match this 'bean field', or will a matching
one also be generated (thusly leaving me with 2 methods??) Does
capitalization of the first letter matter?
c. members: what classtype, in full package form, is contained in the
'bean field' of this object.
In this case, 'profile' contains a user.interfaces.UserProfileLocal. I
believe this is necessary incase this method returns a Collection, rather
than a single item.
d. members-name: ??
My guess is that this is the method name, minus the get, that --should be
present-- in the class referenced by members in order to get the class
referenced by the aggregate/compose.
ie, if my parent class is Foo, and it contains a child Bar:
-- compose = com.interfaces.BarValue
-- members = com.interfaces.BarLocal
-- members-name = BarValue
means that: com.interfaces.BarLocal should have a method 'getBarValue()'
that returns a 'com.interfaces.BarValue' object.
Or, does it expect the method 'getBarValue()' should exist, and I should
really just use 'Bar' for members-name, and it will plug in the 'get' and
the 'Value' in the generated code? Is the case of the first letter
important?
I've tried putting all sorts of funny values in the members-name, just to
trace where it ends up. And I can never find it in any of the code. So,
now I'm really confused.
To make it worse, there's a listing in the documentation for @ejb.aggregate:
@ejb.aggregate (0..1)
Mark a persistent field containing a reference to another entity bean as
being aggregated in this bean. The data object will contain accessor methods
for the aggregated entity's data object instead of a reference to the entity
itself. The aggregated entity will also be removed when this entity is
removed. For example, aggregates are useful for sending graphs of data to
the client. This is only applicable to entity beans and has no parameters.
How does this relate to the scheme of things? Is this referring to
myClassData, myClassValue, myClass, or myClassDAO ? "The aggregated entity
will also be removed when this entity is removed" Cascade delete removed?
entity removed from the data store? or just from memory?
I guess what would really help are well documented examples, showing
resulting code of where things end up.
So, if you can answer any of my questions, or shed light on my confusion,
I'd be greatly appreciative. I'll even contribute a document, to help
confused souls like myself, for inclusion with the documentation on all this
once I get an understanding.
Thank you very much.
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user