-->
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.  [ 3 posts ] 
Author Message
 Post subject: Can NHibernate do table per concrete class mapping?
PostPosted: Fri May 27, 2005 2:39 am 
Newbie

Joined: Thu May 26, 2005 2:37 am
Posts: 3
Location: Czech Republic
It seems that feature (table per concrete class) was added to Java Hibernate 3. Unfortunately NHibernate was ported from Hibernate 2 and there is no <union-subclass> element.

But I still hope experimenced developers will know any trick how to map the following scenerio:

I have base abstract class Employee and tow subclasses: DefaultEmployee and ExternalEmployee, each with different bussiness behavior. There are two tables in my database, where some columns (personal number, name, title and email) are exactly the same, other columns differ - this is suited to <union-subclass>. It might be better to redesign the database to suit the <joined-subclass> mapping strategy. But i can't make any changes to this legacy database because it would break another applications.

Is there any workaround how to make this "table per concrete class mapping" in NHibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 4:25 am 
Beginner
Beginner

Joined: Thu May 12, 2005 3:41 am
Posts: 24
Location: London, UK
<union-subclass> was added in Hibernate 3 and isn't implemented in NH; however Hibernate 2 supports table per concrete class using implicit polymorphism (see
http://www.hibernate.org/hib_docs/reference/en/html/inheritance.html#inheritance-strategies). I haven't use this in NH, but I can't see any reason why it shouldn't work.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 5:25 am 
Newbie

Joined: Mon May 16, 2005 5:58 am
Posts: 11
Location: Galicia, Spain
if the keys of the tables are different you can create a table Person with only the id and use de <joined-subclass> mapping strategy.
With this way you don


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