-->
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: inheritance *only* on object-side
PostPosted: Mon Dec 03, 2007 5:53 pm 
Newbie

Joined: Mon Oct 01, 2007 11:50 am
Posts: 4
Hi all,

I have a situation in which inheritance is only meaningful on the object side: I'd like to write java code around the superclass, but I will only ever query for instances of a subclass. I don't want to have a table for the parent class, because I expect huge numbers of entries on the subclasses and would rather not index across all subclasses when I know my queries will be confined one.

One solution is to "hide" the inheritance from hibernate -- don't map the parent, map the subclasses as seperate classes. Is this correct, or is there some way to inform hibernate of the inheritance without having a parent table?

Thanks,
G


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 04, 2007 12:05 am 
Newbie

Joined: Fri Aug 31, 2007 11:58 am
Posts: 19
Well their are different type of Strategies for tackling inheritance in Hibernate.

* Table per Class Strategy:

* Single Table per Class Hierarchy Strategy:

* Joined Subclass Strategy:

Just go through http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html

Read the Section : 2.2.4. Mapping inheritance

It seems what you want is mapping of only Concrete Classes.This way you have inheritance at Object side but hibernate will take care of mapping this inheritance to DB Schema.

_________________
Note:Don't forget to rate,if useful.

Blog:http://elope.wordpress.com/


Top
 Profile  
 
 Post subject: concrete it is
PostPosted: Tue Dec 04, 2007 3:35 pm 
Newbie

Joined: Mon Oct 01, 2007 11:50 am
Posts: 4
thanks, that's exactly what I should do. I knew about hierarchy and subclass, but had not heard of table-per-concrete class.

Cheers,
G


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 07, 2007 4:38 am 
Newbie

Joined: Fri Aug 31, 2007 11:58 am
Posts: 19
Hey it helped you and you have not rated the post :(

_________________
Note:Don't forget to rate,if useful.

Blog:http://elope.wordpress.com/


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.