-->
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: mapping same property into 2 columns
PostPosted: Tue Jul 26, 2005 10:09 am 
Beginner
Beginner

Joined: Mon Jun 20, 2005 3:14 pm
Posts: 33
Hi,

I have a special stuation that I need to map one property into two columns. Is it possible? I've tried this mapping:

Code:
<many-to-one name="classe" class="Classe">
  <column name="COD_CLASSE" scale="11" precision="0" not-null="false" />
  <column name="COD_TIPO_OCORR" scale="11" precision="0" not-null="false" />
</many-to-one>


But received this error:

org.hibernate.MappingException: Foreign key (FK6B08A21A2E6A76F6:OCORRENCIA_SUBTRANSMISSAO [COD_CLASSE,COD_TIPO_OCORR])) must have same number of columns as the referenced primary key (CLASSE [COD_CLASSE])


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 11:01 am 
Beginner
Beginner

Joined: Fri May 21, 2004 12:21 pm
Posts: 22
Location: Sacramento CA, USA
This error is not because of mapping 2 col into 1 property. Check the <set> and/or the <id> of the parent class. That also should have same number of columns as of this <many-to-one tag>.
Also i found that the order in which you put this column in the set and many-to-one tag matters.
When i tried to reverse it my join came wrong.

Hope this helps.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 1:51 pm 
Beginner
Beginner

Joined: Mon Jun 20, 2005 3:14 pm
Posts: 33
I solved the problem creating a new <one-oto-one> tag...

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 1:51 pm 
Beginner
Beginner

Joined: Mon Jun 20, 2005 3:14 pm
Posts: 33
I solved the problem creating a new <one-to-one> tag...

Thanks!


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