Title: How do I use ejb:value-object?
This is a re-post of Vincent's explanation from awhile back:
 
 
==============================================
 
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: JD Brennan
Sent: Friday, April 05, 2002 8:01 PM
Subject: [Xdoclet-user] How do I use ejb:value-object?

Is ejb:value-object working in 1.1.2?

I tried:

    /**
     * @ejb:interface-method
     * @ejb:value-object match="normal"
     */

in my Bean.java file and

   <valueobject/>

subtask in the Ant build file, which produces this output:

xdoclet:
Generating Javadoc
Javadoc execution
Loading source file /home/brennan/java/cmp2/ejb/DeviceInfoBean.java...
Constructing Javadoc information...
Running <remoteInterface/>
  Generating Remote interface for 'DeviceInfoBean'.
Running <localInterface/>
  Generating Local interface for 'DeviceInfoBean'.
Running <valueobject/>

BUILD SUCCESSFUL

Looks like it's running the value object stuff, but I don't get
the Generating Value Object classes... output which
ValueObjectSubTask.java outputs.

Thanks for any hints on what I might try next!
JD

P.S. Is there a way to search the mailing list archive?  I
couldn't find one at geocrawler.

Reply via email to