-->
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.  [ 2 posts ] 
Author Message
 Post subject: component mapping with many-to-one association not persising
PostPosted: Tue Jun 03, 2008 1:14 pm 
Newbie

Joined: Tue Jun 03, 2008 12:57 pm
Posts: 2
hi guys,
i have a problem with persisting this object:
Hibernate version: 3.2.5

Mapping documents:
<class name="model.order.domain.Order" table="orders">
<id name="id" column="id" >
<generator class="sequence">
<param name="sequence">order_id_seq</param>
</generator>
</id>
<property name="invoiceNumber" column="invoice_number"/>

<component name="grandTotal" class="model.money.domain.Money">
<property name="amount" column="grand_total"/>
<many-to-one name="currency" column="currency_id" formula="currency_id" class="model.money.domain.Currency" cascade="all" />
</component>

<component name="priceTotal" class="model.money.domain.Money">
<property name="amount" column="price_total"/>
<many-to-one name="currency" column="currency_id" formula="currency_id" class="model.money.domain.Currency" cascade="all" />
</component>

<component name="discountTotal" class="model.money.domain.Money">
<property name="amount" column="discount_total"/>
<many-to-one name="currency" column="currency_id" formula="currency_id" class="model.money.domain.Currency" cascade="all" />
</component>

<component name="feeTotal" class="model.money.domain.Money">
<property name="amount" column="fee_total"/>
<many-to-one name="currency" column="currency_id" formula="currency_id" class="model.money.domain.Currency" cascade="all" />
</component>
</class>

So i map (grand_total,currency_id) and (price_total,currency_id) and (discount_total,currency_id) and (fee_total,currency_id) in 4 different Money objects but using the same column currency_id.
While loading of these objects works very well, i have a problem with the persist part; the currency_id column is not included in the generated sql for the insert of the order and i don't understand why because i put cascade="all" for every object.

why doesn't persist also the currency_id column ?

thanks,
viorel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 03, 2008 1:31 pm 
Newbie

Joined: Tue Jun 03, 2008 12:57 pm
Posts: 2
i figured it out ; i changed the mapping as follows:

<component name="grandTotal" class="model.money.domain.Money">
<property name="amount" column="grand_total"/>
<many-to-one name="currency" formula="currency_id" class="model.money.domain.Currency" cascade="all" />
</component>

<component name="priceTotal" class="model.money.domain.Money">
<property name="amount" column="price_total"/>
<many-to-one name="currency" column="currency_id" class="model.money.domain.Currency" cascade="all" />
</component>

<component name="discountTotal" class="model.money.domain.Money">
<property name="amount" column="discount_total"/>
<many-to-one name="currency" formula="currency_id" class="model.money.domain.Currency" cascade="all" />
</component>

<component name="feeTotal" class="model.money.domain.Money">
<property name="amount" column="fee_total"/>
<many-to-one name="currency" formula="currency_id" class="model.money.domain.Currency" cascade="all" />
</component>

viorel


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