Hello.
I am trying to implements a mixed
joined-subclass and
subclass inheritance diagram.
The reason I want to do that for is that I have a number of root classes that define little or no persistant fields, but I have a couple of child classes that have a lot of information.
Code:
<<persistant>>
.--------------ACTOR---------------.
| (id, name) |
v v
<<persistant>> <<persistant>>
.----ROLE------. .----PARTICIPANT---.
| (no data) | | (no data) |
v v v v
<<persistant>> <<persistant>> <<persistant>> <<persistant>>
ROLE_X ROLE_Y USER PARTNER
(10K blob) (20k clob) (place, position) (address, PERSON)
So...
I wanted ACTOR, ROLE and PARTICIPANT mapped into one table with
subclass.
ROLE_X, ROLE_Y, USER and PARTNER mapped into different sub-class tables using
joined-subclass.
So I did.
Code:
<class name="com.Actor" table="ACTOR" discriminator-value="none">
<id column="ID"><generator class=native"/></id>
</class>
<subclass name="com.Role" extends="com.Actor" ... discriminator-value="ROLE" >...</subclass>
<subclass name="com.Participant" extends="com.Actor" ... discriminator-value="PARTICIPANT">...</subclass>
<joined-subclass name="com.RoleX" extends="com.Role" table="ROLES_X"><key column="ID"/>...</joined-subclass>
<joined-subclass name="com.RoleY" extends="com.Role" table="ROLES_Y"><key column="ID"/>...</joined-subclass>
<joined-subclass name="com.User" extends="com.Participant" table="USERS" ><key column="ID"/>...</joined-subclass>
<joined-subclass name="com.Partner" extends="com.Participant" table="PARTNERS"><key column="ID"/>...</joined-subclass>
Did I forget to mention, that I was thinking of a modfular extension of these classes?
Anyway...
When I try to insert an instance of User:
Code:
java.sql.SQLException:
Column not found: LOCATION in statement
[
insert into ACTORS (
place,
position,
ENTITY_TYPE,
ID)
values (
'Home',
'Watchdog',
'com.User',
null)
]
I get the impression, that Hibernate does not handle correctly this situation. It tries to insert the join-table fields into the root table.
I have read the dos and it says:
Quote:
It is even possible to use different mapping strategies for different branches of the same inheritance hierarchy, but the same limitations apply as apply to table-per-concrete class mappings. Hibernate does not support mixing <subclass> mappings and <joined-subclass> mappings inside the same <class> element.
And all of the classes that inherit a certain parent have one and the same inheritance strategy.
Please help.
Lachezar
P.S:
Code:
15:52:47,390 INFO [ Environment] Hibernate 2.1.2
I can provide java code, stack trace, full mapping documents and/or debug log if I have to. I just think they are too bulky to attach here.