-->
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: single DB column mapped to multiple properties.
PostPosted: Tue Feb 03, 2004 9:29 pm 
Newbie

Joined: Tue Feb 03, 2004 9:14 pm
Posts: 2
Hi,
I have a table which has the following structure.
currency varchar2(4),
amount1 double,
amount2 double

My Object model looks something like below
class Something {
Amount amount1;
Amount amount2;
}

class Amount {
String currency;
double amount;
}

I would like to map the single column currency to each amount field.
my hbm looks something like below
<component name="amount1" type="Amount">
<property name="currency" column="currency">
<property name="amount" column="amount1">
<component>
<component name="amount2" type="Amount">
<property name="currency" column="currency" insert="false" update="false">
<property name="amount" column="amount1">
<component>

Though the schemaexport utility works fine with this, at run time I get a mapping exception.
Any help would be greatly appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 9:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use:

<component name="amount1" type="Amount">
<property name="currency" column="currency">
<property name="amount" column="amount1">
<component>
<component name="amount2" type="Amount" insert="false" update="false">
<property name="currency" column="currency">
<property name="amount" column="amount1">
<component>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 9:57 pm 
Newbie

Joined: Tue Feb 03, 2004 9:14 pm
Posts: 2
Hi Gavin,
Firstly THANKS A LOT !! for this extremely prompt reply. I truly apologise for the mistake in the code posted. The hbm fragment should read as below... i.e the component amount2 is presisted as amount2 column. The currency field is common.

<component name="amount1" type="Amount">
<property name="currency" column="currency">
<property name="amount" column="amount1">
<component>
<component name="amount2" type="Amount">
<property name="currency" column="currency" insert="false" update="false">
<property name="amount" column="amount2">
<component>

I truly apologise for wasting your time.

Thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 10:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ah, so currently, and for the forseeable future, some mapping attributes do not apply to properties of a component. The insert and update attributes are like this. Unfortunately, this would be very difficult to change.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 03, 2004 2:52 pm 
Newbie

Joined: Sun Feb 08, 2004 2:44 pm
Posts: 1
and how can i solve this problem with xdoclet. xdoclet have one attribute [code]class
and [b]not [/b][/code]name?


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.