-->
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: Problems with Inheritance mapping
PostPosted: Thu Jun 16, 2005 7:46 am 
Newbie

Joined: Wed Jun 15, 2005 1:31 pm
Posts: 2
Hi all.
We have such db structure - main table with id, and set of table which id is foreign key to main table.
In application we want to have such class hierarchy - super class, mapped to main table, and for other table we want have ClassShort(small amout of columns are used, for example to use in list), which extends Super class, and ClassFull(whole amount of columns) which extends ClassShort.

So the question is how to mapp such structure. Hibernate v3


The problem is that we have to mix here to different strategies(table-per-subclass and table-per-class hierarchy). One solution I found is to use <subclass> whith <join>, but we do not have any discriminator column. Another way is to map ClassFull as joined-class to SuperClass and ClassShort separatly with polymorphism="explicit" and mutable="false", it will work, but seems not elegant :)

Thanks for help in advance


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 9:20 am 
Beginner
Beginner

Joined: Mon Apr 11, 2005 8:37 am
Posts: 22
Why do you have to mix table-per-subclass and table-per-class-hierarchy here? I think table-per-subclass fits perfectly well for your case - you can extend your super class by classShort using <joined-subclass> and then extend classShort again with a <joined-subclass> representing classFull. There should be no problem that classFull and classShort use the same table.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 10:50 am 
Newbie

Joined: Wed Jun 15, 2005 1:31 pm
Posts: 2
The problem is that hibernate trys to do 2 SQL querries for ClassShort and ClassFull. So we get 2 new columns instead 1 or exception if table has NOT NULL constraint


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 11:40 am 
Beginner
Beginner

Joined: Mon Apr 11, 2005 8:37 am
Posts: 22
ok, I got your point - but no solution to it.
not-null constraints pose a real problem.
A possible way would be using views in the database (if supported).


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.