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.  [ 9 posts ] 
Author Message
 Post subject: table per concrete class persistancy
PostPosted: Tue Nov 18, 2003 8:11 am 
Newbie

Joined: Tue Nov 04, 2003 4:48 am
Posts: 12
Location: Iran
I could not find any clue of table-per-concrete-class persistancy anywhere in the documents, but it mentioned in the feature list. I wonder is it supported in the hibernate and how can I use it (preferrebaly using xdoclet)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 8:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
There is no special mapping required. Just map each subclass using <class>. Hibernate handles polymorphis queries using "implicit" polymorphism, and you can map a polymorphic association using <any>.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 9:41 am 
Newbie

Joined: Tue Nov 04, 2003 4:48 am
Posts: 12
Location: Iran
i couldn't get you :(
Let me describe my problem. I have a resource class which has only one field: resourceId. i want my partner class and machine - that both are very heavy classes- inharite from resource. I really don't want to create a table for resource class, bu ti want to add a field for resourceId in each subclass of resource class. What shall I do?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2003 1:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Code:
<class name="concreteClass1" ...>
<id name="resourceId"...>
[...]
<class name="concreteClass2" ...>
<id name="resourceId"...>

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 2:16 am 
Newbie

Joined: Tue Nov 04, 2003 4:48 am
Posts: 12
Location: Iran
emmmmmm, and after that will hibernate handle the selection on resource class? Can I use a forexample get Resources() and cast it to cmy concrete classes?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 2:33 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Sure. Just map the association using <any>


Top
 Profile  
 
 Post subject: re:about the querying thing..
PostPosted: Wed Mar 16, 2005 12:16 am 
Newbie

Joined: Tue Mar 15, 2005 11:57 pm
Posts: 4
hello hibernate guys,

"SecParaDetailed" is a superclass of many classes I used as a table in my hibernate mapping. I used table-per-concrete-class inheritance mapping strategy because I do not want to create a table for "SecParaDetailed". How do I query all its subclasses together with the "class property". Do I need to use the <any> tag you are mentioning? Or should I use "discriminator-value" instead to be able to query its "class property"? I need to query the "class property" because I want to distinguish one subclass from the other.

Thanks in advance! :)

_________________
Hibernate rocks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 12:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I would strongly recommend upgrading to HB3 and using <union-subclass> if you want full queryability of associations.


Top
 Profile  
 
 Post subject: how about in HB2
PostPosted: Wed Mar 16, 2005 12:40 am 
Newbie

Joined: Tue Mar 15, 2005 11:57 pm
Posts: 4
follow - up question:

Is there any way I can implement this type of query using this HB2? How about compatibiliy issues in my hbm.xml files created for HB2. And I think this is more of an issue of inheritance rather than association.

Thanks! You're the King! :)

_________________
Hibernate rocks!


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