-->
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.  [ 11 posts ] 
Author Message
 Post subject: inheritance in hibernate
PostPosted: Mon Apr 26, 2004 12:21 pm 
Newbie

Joined: Mon Apr 05, 2004 10:40 am
Posts: 19
i want know how to implement inheritance in the file *.hbm.xml

thanks for all your suggestions


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 12:22 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
first suggestion: read the doc ;)

http://www.hibernate.org/hib_docs/refer ... tance.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 1:01 pm 
Newbie

Joined: Mon Apr 05, 2004 10:40 am
Posts: 19
if i use table-per-subclass mapping
what i must put in file hbm per sub-classes

thants for other suggestions


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 1:06 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
A table-per-subclass mapping would look like:

<class name="Payment" table="PAYMENT">
<id name="id" type="long" column="PAYMENT_ID">
<generator class="native"/>
</id>
<property name="amount" column="AMOUNT"/>
...
<joined-subclass name="CreditCardPayment" table="CREDIT_PAYMENT">
<key column="PAYMENT_ID"/>
...
</joined-subclass>
<joined-subclass name="CashPayment" table="CASH_PAYMENT">
<key column="PAYMENT_ID"/>
...
</joined-subclass>
<joined-subclass name="ChequePayment" table="CHEQUE_PAYMENT">
<key column="PAYMENT_ID"/>
...
</joined-subclass>
</class>



Actually i think you have a problem, so explain it or if you don't have a precise problem read the doc


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 1:12 pm 
Newbie

Joined: Mon Apr 05, 2004 10:40 am
Posts: 19
i want to know what i must put in fine CreditCardPayment.hbm.xml?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 1:35 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
oh, if you follow this example, you just need one xml file for the main class and all its subclasses


Top
 Profile  
 
 Post subject: mapping inheritance
PostPosted: Mon Apr 26, 2004 1:44 pm 
Newbie

Joined: Mon Apr 05, 2004 10:40 am
Posts: 19
then if i want to persist the sub-class without insantancing the main class
i must have hmb.xml file NO??


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 1:45 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
no, it will work without problem


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 1:45 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please, read the documentation and also try to understand it! This is really trivial. No, instances have nothing to do with classes/mappings of classes.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: mapping inheritance
PostPosted: Mon Apr 26, 2004 1:51 pm 
Newbie

Joined: Mon Apr 05, 2004 10:40 am
Posts: 19
i want to say: if i make

...

sub-class.save();

it works or no?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 26, 2004 1:53 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
it will not since you must call session.save(subclass....

Sunes, you'll have all the help you need here but if you don't take the time to read the doc and to test by yourself, people will soon stop helping you... just an advice


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