| Author |
Multiple subclasses, one superclass in Hibernate.
|
Kristofer Hindersson
Greenhorn
Joined: Jan 19, 2010
Posts: 25
|
|
Hi, is this possible (using hibernate or-mapping):
...and how would I go about it?
/Regards Kris
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4962
|
|
Where did this scenario come from?
I'm curious about the DTYPE field in the two tables. It would appear that this has already been mapped, as DTYPE is the standard attribute used to distinguish between object types that share an inheritance hierarchy. Curious, as I usually see that with a one-table mapping strategy, but here you have two tables. For example, here is an inheritance hierarchy, and then the single table that is created for it:
Here's a tutorial on mapping inheritance:
Mapping Inheritance with Hibernate
-Cameron McKenzie
|
Author of Hibernate Made Easy, What is WebSphere???, JSF 2.0 Made Easy and the SCJA Certification Guides
|
 |
Kristofer Hindersson
Greenhorn
Joined: Jan 19, 2010
Posts: 25
|
|
Hi, thanks for another quick reply. The scenario I've depicted is one I made up to illustrate the hypothetical situation of a non-linear inheritance. I used your example from Hibernate made easy as a base. The problem is that the book only deals with the linear case of inheritance (Ancestor <- Parent <- Child). Let's say that I have a Person-class which holds attributes like firstname and lastname and then want to create the two classes Administrator (with a password attribute) and User, both of which extends Person. I don't want the administrators password to be stored in the same table as that of the user and I don't want use separate tables for Person, Adminstrator and User etc. Would hibernate support using the single table strategy, only separately for Person<-Administrator and Person<-User? I hope I'm not confusing the issue..
Regarding the DTYPEs I just put them there thinking it would be how it would work out (it's probably wrong though?)
/Kris
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4962
|
|
|
Hmmmm......I'm going to have to think about that...
|
 |
 |
|
|
subject: Multiple subclasses, one superclass in Hibernate.
|
|
|