File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
EJB and other Java EE Technologies
Joined: Jul 29, 2005
Sep 28, 2006 07:04:00
I have a issue with implementing inheritance with a database design. The design is like this (somewhat simplified for readability)
id INTEGER PK
type INTEGER FK (PERSON_TYPE.id)
id INTEGER PK
decode VARCHAR <--- This is the DISCRIMINATOR
The relations is like this:
PERSON ---> PERSON_TYPE ---> EMPLOYEE/CUSTOMER
Is there anyway to solve this? The problem seems to be that the descriminator column is not in the parent class/table (person) but in a "codes table"
SCJP 1.4, SCBCD 1.3, SCBCD 5.0, SCEA J2EE, SCEA 5.0
Joined: Oct 05, 2006
Oct 05, 2006 10:56:00
In your model, can you make PERSON a @MappedSuperclass instead of an @Entity? If so, you can have PERSON_TYPE be the root of the inheritance hierarchy, and it can be the entity that specifies the @DiscriminatorColumn.
subject: JPA Inheritance
Foriegn key mapping
Need help on one-to-one - child data not getting saved
multiple composit key
one-to-one mapping issue.
Hibernate: Can someone verify my mapping configuration?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014