aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Value objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Value objects" Watch "Value objects" New topic
Author

Value objects

Mallika Kumar
Ranch Hand

Joined: Feb 15, 2001
Posts: 61
Hi,
From what I understand, value objects are a convenient way of reflecting database table columns, which can be used in entity beans. They have private variables which correspond to the columns in the database table,with accessor and mutator method for getting and setting these values. The reason for making the data private is for data hiding, right ? What if we have all the variables in the value objects as public, and not have accessor and mutator methods for them ? Will this be a desin flaw, or will it pose new problems on the long run in an application ? Any response will be very helpful.
Thanks.
Vivek Viswanathan
Ranch Hand

Joined: Mar 03, 2001
Posts: 350
hi
Yes you are right, the basic reason for making variables private is for data hiding, and by making them public, you are in a way violating the basic concept of data hiding that Objects provide you. This statement is particularly debate able since all that you are creating is Value Objects that do on contain any processing but just act as a Storage area for transferring data from one tier to another.
I have almost the similar problem in the project that I am working on, we are using Value Objects as the super class to the Entiy Bean class, since we are using Container Managed Persistence all the attributes of the Value Object have to declared as public. The reason for this inheritance is to increase code reuse and reduction in code duplication that results in creating two classes that contain exactly the same fields. I feel that since I am extending Entity Beans from Value Object and the Entity Bean (with Container Manager Persistence) requires that all the database field variables be declared as public, it is all right to use this pattern even though it does not stick the OO Concept of Data encapsulation.
I hope I was helpful :-)
Vivek Viswanathan

Vivek Viswanathan SCJP 1.2, SCJP 1.6,SCJD,SCEA,SCWCD,IBM-484,IBM-486,IBM-141,Ms.NET C# 70-316,SCMAD, LPIC-I
Saran Vel
Ranch Hand

Joined: Nov 03, 2000
Posts: 111
Hi Vivek,
In the case u have mentioned, what abt using ejb2.0, such that the value object can have private variables ?
In this case i can use abstract get and set methods of the entitybean to set values in the EJB,and by passing the value object between client and EJB. What r the pros and cons of this design?


Saran
Sun Certified Java2 Programmer
Vivek Viswanathan
Ranch Hand

Joined: Mar 03, 2001
Posts: 350
Hi
I still have to go through EJB2.0 Spec, I have not read it.
Do any Appservers support EJB2.0 ?
I am using Weblogic 5.1
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
Vivek,
WL 6.0 Beta 2 supports the ejb 2.0 spec and all u have to do is include a new jar called ejb20.jar in the classpath.
Sahil


Adios
Mallika Kumar
Ranch Hand

Joined: Feb 15, 2001
Posts: 61
Thanks for the feedback. It cleared up many doubts.
Vivek Viswanathan
Ranch Hand

Joined: Mar 03, 2001
Posts: 350
Thanx
I have to try out WL 6.0 beta
Is the final release of WL 6.0 avaliable for Linux -- any ideas on that ???
vivek
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Value objects