Some (perhaps all?) major J2EE servers allow a single CMP entity bean to
obtain its data from multiple tables. I wish to use this feature to
implement inheritance, and I would like to know if it is:

A) Allowed and appropriate under the existing J2EE standards and
B) A good idea


Suppose I have an entity bean called User.
It has the following fields:

Integer id;
String username;
String password;
String type;

and is mapped to a table called Users.

I want to create a subclass of User called Researcher. I want the entity
bean to have the following fields:

Integer id;
String username;
String password;
String type;
String firstName;
String lastName;
String affiliation;

I want to map the first four fields to the Users table and the last
three fields to a Researchers table which would also have an id field
for the purpose of joining the two together.

Now I have two beans, one of which is logically a subclass of the other
but which have no formal relationship as far as the EJB container goes,
sharing the same database columns. When I want to manipulate all users I
can use the User bean. When I want to deal with just Researchers, I can
use the Researcher Bean. I can use the type field to inform me which
users are also researchers if I ever need to know this.

Is this legal and/or appropriate as far as the specs are concerned?
Is it a good idea?
If not, what other techniques are people using?

Thanks,

JWS

===========================================================================
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".

Reply via email to