-->
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.  [ 1 post ] 
Author Message
 Post subject: Foreign key not the same type! Mapping problem
PostPosted: Fri Sep 02, 2005 1:31 pm 
Senior
Senior

Joined: Tue Jan 11, 2005 5:03 pm
Posts: 137
Location: Montreal, Quebec
Hi,

I have a difficult mapping issue. I am mapping a legacy database and there is a problematic of datatype for a one-to-many mapping between 2 tables: Parent to Children.

I have a Parent that is linked to a Set of Childrens:
Code:
   <set name="childrens" lazy="true" inverse="true">
      <key foreign-key="FinancialTransit">
         <column name="transit" scale="10"
         precision="0" not-null="false" unique="true" />
      </key>
      <one-to-many
            class="com.eg.Children" />
   </set>


The problem I have is that the data-type of Parent.FinancialTransit is a NUMERIC and the data-type of Children.transit is a CHAR!

So I would need to put a formula somewhere to tell Hibernate to convert the FinancialTransite from NUMERIC to CHAR before comparing it to transit. Is that possible? I know I could do this in SQL, but in Hibernate mapping I am not sure how to do this.

This would be the formula:

Code:
convert(VARCHAR(3), FinancialTransit)



Thanks

Etienne.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.