wood burning stoves
The moose likes EJB and other Java EE Technologies and the fly likes Design Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Design Question" Watch "Design Question" New topic

Design Question


Joined: Jun 30, 2006
Posts: 23
Can a Value object (Transfer object pattern) and persistance object have "USING" relationship ?

That is ValueObject's overloaded constructor will take persistance object as parameter and get the details of persistance object and set the details to its member variables.

My question here is , is it a correct design ? or shoud i use any static method in ValueObject to give a instance of valueobject with the details or an external method (out of value object ) which will create a value object with details from persistance object.

Thanks in Advance
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
If I were to design an application with Value Objects and Persistence Objects in an EJB environment which uses component based architecture, then I would not have such kind of Constructor in my ValueObject.

If you have such constructor or method in the value object (persistence object as a parameter) then you are coupling your value object to the persistence object. I would infact have my value object (serializable) and have it populated using a Utility class(with static methods) on the server side which can populate value object from the persistence object and vice versa.

So this value object can be used in your web layer as well as EJB layer without having the class definition to be dependant on the Persistence Class def.

Amit Tank
Linked In
kiran mathew

Joined: Jun 16, 2008
Posts: 16
It would be easy to add a constructor to the persistence object, which would have the value object as input and to have a method getValueObject() which would return the value object.
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

"kiran mw",
Please check your private messages.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link: http://aspose.com/file-tools
subject: Design Question
It's not a secret anymore!