A Scheme for CMP Entity Inheritance: Is it allowed under the standard? Is it a good idea?

"Jason W. Solinsky - Silver Bullet Software" <[email protected]>
Newsgroups gmane.comp.java.sun.ejb.general
Message-ID <B79C9CF3D26CF843AE6DB800EBC4BB890E1FD6@snuffleupagus.hq.entropy-labs.com>
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".
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.