-->
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.  [ 5 posts ] 
Author Message
 Post subject: table per class hierarchy mapping
PostPosted: Sat Dec 03, 2005 8:46 am 
Newbie

Joined: Sat Dec 03, 2005 8:41 am
Posts: 11
hi,
i am new to hibernate. i have a query.

i have the following class heirarchy

Interface A
Class B implements A

Class C extends B
Class D extends B
Class E extends B

Class F extends C

What will be the mapping for this if i were to use table per class hierarchy


Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 03, 2005 9:07 am 
Newbie

Joined: Sat Dec 03, 2005 8:41 am
Posts: 11
i forgot to mention that class B is an abstract class.


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 03, 2005 11:38 am 
Newbie

Joined: Sat Dec 03, 2005 8:41 am
Posts: 11
what i wanted to know was that we do not store the state of C in the data store. so should my mapping be

<hibernate-mapping>
<class name="B" ..... >
<discriminator column = ......>

<subclass name ="C" discriminator-value="C" >
<subclass name = "F" discriminator-value="F" >
....
</subclass>
<subclass>
</class>
</hibernate-mapping>

OR

<hibernate-mapping>
<class name="B" ..... >
<discriminator column = ......>

<subclass name = "F" discriminator-value="F" >
....
</subclass>
</class>
</hibernate-mapping>

can i directly say omitting the subclass C as its state is not being saved. Class C only has some behavior and no state. do i have to maintain exact hiearchy in my mapping. will hibernate work properly in the second case.
How does hibernate work internally. can anyone point me to some document which mentions internal functioning of hibernate.


Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 04, 2005 10:15 am 
Newbie

Joined: Sun Dec 04, 2005 9:30 am
Posts: 2
if C won´t be persisted, the second mapping excerpt is right.

You only declares the classes that will have some state info saved in a datastore in your Relational Model (remember, Hibernate is a object-relational framework).

So, when you work in a hibernate session block, you will save, update, delete or query the objects whose classes you mapped.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 04, 2005 10:56 am 
Newbie

Joined: Sat Dec 03, 2005 8:41 am
Posts: 11
Thanks for the reply.. i was a bit confused. just wanted to know whether hibernate allows to do it..

Thanks again.


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