-->
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 Mapping
PostPosted: Tue Oct 11, 2005 12:18 am 
Regular
Regular

Joined: Thu Feb 17, 2005 1:58 am
Posts: 63
Hibernate 3.x

The below example is from the docs. Would it be possible to keep the mapping of CreditCardPayment and ChecquePayment in their own separate mapping files? How would I have to update the below mapping?

Thanks,

<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"/>
<property name="creditCardType" column="CCTYPE"/>
...
</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>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 11, 2005 12:06 pm 
Beginner
Beginner

Joined: Wed Sep 21, 2005 11:52 am
Posts: 43
Do this:

Payment.hbm.xml:
Code:
<class name="Payment" table="PAYMENT">
<id name="id" type="long" column="PAYMENT_ID">
<generator class="native"/>
</id>
<property name="amount" column="AMOUNT"/>
...
</class>


CreditCardPayment.hbm.xml
Code:
<joined-subclass name="CreditCardPayment" table="CREDIT_PAYMENT" extends="Payment">
<key column="PAYMENT_ID"/>
<property name="creditCardType" column="CCTYPE"/>
...
</joined-subclass>


CashPayment.hbm.xml
Code:

<joined-subclass name="CashPayment" table="CASH_PAYMENT" extends="Payment">
<key column="PAYMENT_ID"/>
...
</joined-subclass>


ChequePayment.hbm.xml
Code:
<joined-subclass name="ChequePayment" table="CHEQUE_PAYMENT" extends="Payment">
<key column="PAYMENT_ID"/>
...
</joined-subclass>


See section 5.1.14 of the reference manual.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 2:36 am 
Regular
Regular

Joined: Thu Feb 17, 2005 1:58 am
Posts: 63
Works well, except that for <joined-subclass>, I cannot specify "discriminator-value". The doc seems to say it is ok, but DTD does not seem to allow that....

SEVERE: Error parsing XML: XML InputStream(9) Attribute "discriminator-value" must be declared for element type "joined-subclass".


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 11:20 am 
Beginner
Beginner

Joined: Wed Sep 21, 2005 11:52 am
Posts: 43
hiberdude wrote:
Works well, except that for <joined-subclass>, I cannot specify "discriminator-value". The doc seems to say it is ok, but DTD does not seem to allow that....

SEVERE: Error parsing XML: XML InputStream(9) Attribute "discriminator-value" must be declared for element type "joined-subclass".


You don't need a discriminator value since you have a separate table for each class. The discriminator is needed only when more than one class is stored in the same table.


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.