Thanks for the explanation, Vincent.
I am now using value objects and so far so good.
I understand the difference between Aggregation and Composition, but what is
the difference in terms of what gets generated by XDoclet?

Thanks,

Steve


----- Original Message -----
From: "Vincent Harcq" <[EMAIL PROTECTED]>
To: "'Steve Knight'" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Monday, February 25, 2002 2:14 PM
Subject: RE: [Xdoclet-user] Aggregate DataObjects


OK

You need <valueobject/> subtask

AddressBean have @ejb:value-object name="Address" match="*"
instantiation="eager"
That means that a AddressValue will be created containing all fields of
the entity bean
"eager" means the VO is build on ejbLoad

Customer Bean have
 * @ejb:value-object name="CustomerLight" match="light"
 * @ejb:value-object name="CustomerNormal" match="normal"
instantiation="eager"
 * @ejb:value-object name="Customer" match="*"

3 VO will be build.  CustomerValue containing all fields
CustomerNormalValue contains only fields that have a corresponding
@ejb:value-object match="normal"
For example getCredit()
Etc... For LightValue

You can avoid a field appearing in the VO (for example I XMLized/String
Object that are saved in the DB and SAX them on read.  Then my String
has no meaning in my VO.  I want the object.
Use  @ejb:value-object match="*" exclude="true"
(Account.getLastModifiedDate) to avoid a field to be picked up in the VO
In the opposite use @ejb:value-object name="..." match="..." on non
persistent fields to put it in the VO
See Accountean.getTotalAmount

The attribute relation="external" on a field say this: because the VO is
cached in the bean, sometimes you wan to update some fields because you
did not have an setSth() that killed your VO.  For example TotalAmount
looks at other Account.  The Acount on wich you get the VO, you must
rerun this computation at get time.

Aggregation (1-1)
AccountBean ---> CustomerBean
@ejb:value-object match="*" aggregate="CustomerNormalValue"
aggregate-name="OwnerNormalValue"

Association (1-1)
CustomerBean ---> AddressBean
...

For these look at generated code.  The idea is "responsability" of an
entity bean over its related relationship
For Composition Customer knows he is the master of Address, ....
In all these, aggregate/compose is the Java type of the
aggregate/compose VO (you could read test.interfaces... In fact)
Aggregate-name/compose-name is the name given to the get/set method

Aggregation (1-n)
CustomerBean ---> AccountBean
@ejb:value-object match="*" aggregate="CustomerNormalValue"
aggregate-name="OwnerNormalValue"
...

Association (1-n)
CustomerBean ---> AddressBean
@ejb:value-object
     *       match="normal"
     *       type="Collection"
     *       relation="external"
     *       compose="test.interfaces.AddressValue"
     *           compose-name="ShippingAddressValue"
     *       members="test.interfaces.Address"
     *           members-name="ShippingAddress"

For 1-n I also need the type of what is in the Collection so the members
and members-name
For 1-n relation="external" should always be used.

Finally this has not been tested and was written with CMP 1.1 in mind,
so more work will be needed for sure.
This covers more than Data Object but I am listening to any improvements
that could be added...

Vincent


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]] On Behalf
> Of Steve Knight
> Sent: lundi 25 f�vrier 2002 16:30
> To: [EMAIL PROTECTED]
> Subject: Re: [Xdoclet-user] Aggregate DataObjects
>
>
> Hi Vincent,
> Would you mind providing a brief explanation of how to use
> ValueObjects.  I am looking at the XDoclet samples, but I
> think an explanation might be helpful as well.
>
> Thanks,
>
> Steve
>
>
>
> ----- Original Message -----
> From: "Vincent Harcq" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Monday, February 25, 2002 8:12 AM
> Subject: RE: [Xdoclet-user] Aggregate DataObjects
>
>
> > Aggregation on _DataObjects_ works only for 1-1
> relationship. For 1-n,
> > you may want to look at _ValueObject_ (only in cvs and not fully
> > tested).  It is a kind of _DataObject_ but more sophiticated.  We
> > introduced there  1-n relationships (as well as multiple VO
> per entity
> > bean with bean's attributes matching facility,
> > aggregation/composition,
> > ...)  Have a look if you want.  I'll appreciate feedback :)
> >
> > Vincent
> >
> > --- [EMAIL PROTECTED] wrote:
> > > Hi,
> > >
> > > I'm also interested in knowing more about this. From what I
> > > understand is you can put an ejb:aggregate task in the
> javadocs for
> > > a method: eg. for
> > > public abstract Collection getAddresses() in a person
> entity bean and
> > > then I
> > > would get a method in my person value object as follows:
> public void
> > > setAddresses(Collection addresses) and public Collection
> > > getAddresses().
> > >
> > > If I include ejb:aggregate as such I get the following error:
> > >
> > > [ejbdoclet] Running XDoclet failed:
> > > [ejbdoclet] <<The bean implementation class for interface
> > > 'java.util.Collection'  not found!>>
> > > [ejbdoclet] 1 error
> > > [ejbdoclet] 100 warnings
> > > [ejbdoclet] javadoc: In doclet class
> xdoclet.DocletTask$DocletMain,
> > > method
> > > star
> > > t has thrown an exception
> java.lang.reflect.InvocationTargetException
> > >
> > > BUILD FAILED
> > >
> > > What is wrong here?
> > >
> > > Thanks :)
> > > Bernie
> > >
> > > -----Urspr�ngliche Nachricht-----
> > > Von: Steve Knight [mailto:[EMAIL PROTECTED]]
> > > Gesendet: Samstag, 23. Februar 2002 19:15
> > > An: [EMAIL PROTECTED]
> > > Betreff: [Xdoclet-user] Aggregate DataObjects
> > >
> > >
> > > Hello,
> > > Can someone please explain how to use XDoclet to make Aggregate
> > > DataObjects. I realize there is a ejb:aggregate tag, but I'm not
> > > sure how to use it
> > > properly.  And what gets generated?
> > >
> > > Thanks,
> > >
> > > Steve
> > >
> > >
> > >
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Sports - Coverage of the 2002 Olympic Games
> > http://sports.yahoo.com
> >
> > _______________________________________________
> > Xdoclet-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/xdoclet-user
> >
>
> _______________________________________________
> Xdoclet-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-user
>
>
>



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



_______________________________________________
Xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to