-->
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: How to map objects to several tables with SINGLE_TABLE strat
PostPosted: Thu Feb 23, 2006 1:29 pm 
Newbie

Joined: Thu Dec 01, 2005 12:23 pm
Posts: 19
Hi folks,

I'd like to know if and how I could map several objects to several tables when using the SINGLE_TABLE inheritance strategy? For example I got four classes:

Code:
abstract class Class1
abstract class Class2 extends Class1
class Class3 extends Class2
class Class4 extends Class2


And I'd like to have attributes from class Class1 in one table and attributes from classes Class2, Class3 and Class4 in an other, second table.

I've tried with @SecondaryTable, but unfortunately failed. Hibernate generates three (!) forein keys pointing to Class1. Thus when I try to persist a object of type Class3 or Class4 I get a DuplicateKeyException as probably every object in the hierarchy tries to persist its data with the same id on the second table. Using different names for the foreign keys, the same fails due to a forign key constraint.

Any ideas how I could achieve the above mentioned goal?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 01, 2006 11:20 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
it should work, your mapping probably has an issue

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 3:44 am 
Newbie

Joined: Thu Dec 01, 2005 12:23 pm
Posts: 19
Hi Emmanuel,

unfortunately it does not work. The DDL, respectively the database tables are created successfully as desired, but persisting objects of type Class3 or Class4 fails! :(

I guess I need to tell Hibernate to omit creating certain foreign keys.

But if you say that this should be possible, I maybe could supply a testcase that prooves that this does not work.

Regards,
bitbyter


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 8:01 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Create a minimal test case reproducing the problem and send it to JIRA.

_________________
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.