-->
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.  [ 3 posts ] 
Author Message
 Post subject: Foreign key referenced primary key
PostPosted: Tue Jul 19, 2005 7:42 pm 
Newbie

Joined: Tue Jul 19, 2005 7:20 pm
Posts: 2
Location: Bogota Colombia
Im receive the

Foreign key must have same number of columns as the referenced primary key

for the mappin usin join table as show

I can't modify the data base, how i have to make the mapping?

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.0

Mapping documents:
<hibernate-mapping package="com.gml.ib.hb.extracto">
<class name="Portafolio2" table="ad_vlrin">
<composite-id name="id" class="PortafolioId">
<key-property name="codTitu" column="cod_titu" type="java.lang.String" length="10"/>
<key-property name="numTitu" column="num_titu" type="java.lang.String" length="20"/>
<key-property name="canIngr" column="can_ingr" type="java.lang.Long" length="10"/>
</composite-id>

<property name="conCuen" column="con_cuen" type="java.lang.Long" not-null="true" length="9"/>

<join table="ad_adictitulos">
<key>
<column name="cod_titu"/>
<column name="num_titu"/>
<column name="can_ingr"/>
</key>
<property name="conEsta" column="con_esta" type="java.lang.Long"/>
</join>

<join table="lm_cuent">
<key>
<column name="con_cuen"/>
</key>
<property name="nomCuen" column="nom_cuen" type="java.lang.String"/>
</join>

</class>
</hibernate-mapping>


Full stack trace of any exception that occurs:

Name and version of the database you are using:MsSqlServer 2000

Debug level Hibernate log excerpt:
18:04:18,328 ERROR GmlHibernateInit:49 - ERROR: GmlHibernateInit: static: Initial SessionFactory creation failed. Foreign key (f04ad_vlrin:lm_cuent [con_cuen])) must have same number of columns as the referenced primary key (ad_vlrin [cod_titu,num_titu,can_ingr])
org.hibernate.MappingException: Foreign key (f04ad_vlrin:lm_cuent [con_cuen])) must have same number of columns as the referenced primary key (ad_vlrin [cod_titu,num_titu,can_ingr])

_________________
CVS


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 7:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use a many-to-one association, not a <join> since that's what it is!


Top
 Profile  
 
 Post subject: Foreign key referenced primary key
PostPosted: Thu Jul 21, 2005 11:12 am 
Newbie

Joined: Tue Jul 19, 2005 7:20 pm
Posts: 2
Location: Bogota Colombia
Ok

I'm agree, but i don't want to make a POJO object with table="lm_cuent", im need than my class name="Portafolio2" have the property

<property name="nomCuen" column="nom_cuen" type="java.lang.String"/>

that is a column of table referenced by join.

_________________
CVS


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