In the book "Core J2EE Patterns Best Practices and Design Strategies", there
is an Entity Inherits Object Strategy (pg 282) for the Value Object pattern.
This looks like it is close to what you are implementing. In this strategy,
the entity bean extends the value object which has an init method that sets
the object values. The Value Object has 3 constructors, the default, one
constructor with parameters for each property in the VO, and one constructor
with the VO as a parameter. Both constructors call the init method which
sets the VO properties. The following is an example:
public class VendorVO implements java.io.Serializable {
public String seller;
public String description;
public VendorVO () {}
public VendorVO(String seller, String description) {
init(seller, description);
}
public VendorVO(VenderVO vendor) {
init(vendor.seller, vendor.description);
}
// method to set all the values.
public void init(String seller, String description) {
this.seller = seller;
this.description = description;
}
public VendorVO getData() {
return new VendorVO(this);
}
}
public class VendorEntity extends VendorVO
implements javax.ejb.Entitybean {
...
...
}
Danny
----- Original Message -----
From: "Eric Dunn" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 20, 2001 4:22 PM
Subject: Value Object Design Pattern
> Dear all,
>
> I am trying to design a large scale system with optimal EJB communication.
I was wondering with the Value Object Design Pattern, how would a CMP 2.0
spec use the Value Object to SET the values in the entity bean? The way I
retrieve values is exactly how WROX does it in "Professional EJB, Common EJB
Design Patterns Page 520).
>
> There are the mapped variables which are persisted automatically by the
containers persistence engine as normal in the main implementation class. As
a change, the entity bean extends my value object class which has a
getData() method which basically returns this.seller, this.description, etc
in a class.
>
> This is all fine and dandy, as the Value Object is not a field managed by
the bean. But is it possible to set in the same manner, where I send it a
value object (using CMP2.0 keep in mind), and I set the variables then
inside the set method? Should I make a method called
setValueObject(ValueObject v) that calls say setSeller and setDescription()
explicitly? Would this set off then a EJBStore after every set call then? Is
there a way I could have only one EJBStore command be called every time I
set a value object using EJB2.0? Keep in mind I'm trying to avoid BMP.
>
> Warmest Regards,
> Eric Dunn
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".