A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
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.
I agree. Here's the link:
- it saves me about five hours per week
subject: JPA Inheritance
Need help on one-to-one - child data not getting saved
one-to-one mapping issue.
multiple composit key
Foriegn key mapping
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-2013