-->
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.  [ 2 posts ] 
Author Message
 Post subject: inheriting of an inherited object
PostPosted: Tue Dec 06, 2005 4:06 pm 
Newbie

Joined: Sun Oct 09, 2005 11:34 pm
Posts: 6
i have three objects, the first user is parent of mobile_user, then StudentMobileUser and WorkerMobileUser inherit from mobile_user.


User
/ \
| <----------Table per subclass
MobileUser
/\ /\
| | <---------Discriminator
Studen.. Worker...


For the first level im using "Table per subclass" by using this code (Xdoclet) on MobileUser:
/**
* @hibernate.joined-subclass table="mobileuser"
* @hibernate.joined-subclass-key
* column="user_id"
*/

Then i wanted to add the next sub classes, but this time using Table per hierarchy so finally MobileUser is like this:
/**
* @hibernate.joined-subclass table="mobileuser"
* @hibernate.joined-subclass-key column="user_id"
* @hibernate.discriminator column="discriminator" <----"ADDED THIS"
*/
And for Student.. an Worker this are their mappings...
/**
* @hibernate.subclass discriminator-value="S"
*/

WELL, THE PROBLEM is that the first level is OK, i got the user table and mobile_user table, but i does not generates discriminators (on my db schema) for student and worker on mobile_user...

ANY HELP APRECCIATED


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 07, 2005 4:37 am 
Pro
Pro

Joined: Mon Jan 24, 2005 5:39 am
Posts: 216
Location: Germany
Hi,

we had the same problem.
We didnt use xdoclet though.
Creating the mapping manually worked,
but the generated sql was wrong.
For example it used three inserts instead of two.
The only way to get this to work was a custom
entity persister like in:

Code:
   <class name="HibBase"
      table="base1"
      discriminator-value="101"
      persister="MyEntityPersister">


The default persister used by hibernate here
is JoinedSubclassEntityPersister. This can be a starting point
for you. However this was quite difficult for us.

_________________
dont forget to rate !


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.