We need to have a java value object that shuld be passed between client(applet)
and ejb What r the pros and cons in the following two designs
Inheriting Java Object:
By Inheriting the Java Object from the entity bean, the client will get the java object
thru remote interface..
Here the attributes of java object shuld be public..
setting values of the entitybean attributes using abstract set and get methods of
ejb2.0 specification. Here we have attributes of java object as private.
The Entity bean has the following methods..
abstract public void setId(java.lang.String val);
abstract public java.lang.String getId();
abstract public java.lang.String getNumber();
abstract public void setNumber(java.lang.String val);
abstract public void setName(java.lang.String val);
abstract public java.lang.String getName();
public String ejbCreate(DataObject obj) throws CreateException
public void setJavaObject(DataObject obj)
public DataObject getJavaObject()
DataObject det = new DataObject();
Where DataObject is a simple Value Object having attributes and get and setMethods..
Any help will be highly appreciated..
I'm trying to come up with a similiar design pattern that will do basically the same thing, however I'm not entirely happy with what I've come up with.
Currently I have a value object that represents one row fetched from a complex query that accesses multiple tables in our Oracle database. As each row is returned from the java.sql.ResultSet, a value object is created with a constructor that populates all the fields returned from the query and then it is added into a java.util.Vector. The Vector is then returned back to the client as a representation of the original result set and it is then enumerated to retrieve each individual value object. The value object has accessor methods to retrieve the value of each field for each iteration of the Vector.
A Session EJB (version 1.1) wraps the calls to a plain vanilla Java object that performs the connection to the database, runs the query and creates the Vector of value objects to hold the result set.
It works well however one thing that bothers me about this design is the fact that the value object HAS to be in the client's classpath to work.
It would be nice if the current EJB specs supported multiple table access without relying on a tool such as TopLink. Because our data model for our Oracle database is so normalized I am forced to join multiple tables (which are huge, 10 million rows some of them!) together to retrieve the required information. If I was to use an Entity EJB for each table as the specs dictate I am sure that performance would suffer.
When I first looked at the specs for EJB 1.0 I decided then that I would be better off creating my own data access objects to fetch the data. Now I am investigating how I can wrap these objects into an EJB to create a true distributed system.
Any help anybody can give on this I would truly appreciate,
Err, how do you inherit from the EJB? You can implement the remote inteface, or you can inherit from the bean implementation, but there is a whole bunch of generated classes that are what will actually get used. You don't know their name, so you can't extend them.
If what you mean is to use the remote interface of the entity bean then you should note that letting clients have direct access to entity beans is not encouraged in the J2EE blueprints.
If what you want is to pass some value object between client and server, then write a simple value object. You can use a session bean to create these out of entity beans. The bean can do it for you for that matter. It's a value object within the entity bean. In most 1.1. implementations that forces you to use BMP or some OR tool. 2.0 lets you look at dependent objects, which is not final yet so I'd steer clear.
Please comment abt my design..
Can i go head w/ my second design..?