-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Mixing Joined-Subclass and Subclass on different levels?
PostPosted: Thu Apr 01, 2004 9:37 am 
Newbie

Joined: Wed Mar 24, 2004 6:17 am
Posts: 2
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 01, 2004 12:45 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You cannot mix strategies (subclass, joined-subclass)
Try to use one-to-one as a workaround

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 01, 2004 8:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is possible with the new <join> mapping introduced in v22branch. Unfortunately, it will be a while before this functionality is released.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 02, 2004 1:27 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
gavin wrote:
This is possible with the new <join> mapping introduced in v22branch. Unfortunately, it will be a while before this functionality is released.

I had not think of this <join> capability yet. That's cool.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.