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
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