Sidestepping inheritance in entity EJBs

  • Thread starter J. Patterson Waltz III
  • Start date
J

J. Patterson Waltz III

When creating my domain model for an application, I had constructed a domain
model containing inheritance hierarchies such as:

Person
^
|
Employee
^ ^
| \
| Manager
|
Instructor

Problem is, the app will be implemented using (CMP) entity EJBs which don't
offer the usual inheritance possibilities that POJOs do.

I found a way
(http://www.onjava.com/pub/a/onjava/2002/09/04/ejbinherit.html) to do kludgy
entity-bean inheritance, but am assuming EJB developers generally deal with
this otherwise. How?

- Do you "collapse" the hierarchy into one entity which has methods and
properties for all subclasses and perhaps an extra property to indicate what
"class" of entity it is representing?

- Or do you create separate entities and duplicate properties from the
entities that would have been parents to those that would have been
children? If so, would you then persist the resulting data into separate
tables (one per entity) or to columns in a single table (in which case
columns not applying to the row's entity type would be null)

- Or is there some other possibility which is escaping me?

I'd appreciate input from anyone having already addressed such issues in a
real application (as opposed to something overly simplistic such as the
Petstore example provided by Sun).

Thanks in advance.

Patterson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top