-->
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: One-to-may mapping problem because composite keys
PostPosted: Thu Mar 10, 2005 9:51 am 
Newbie

Joined: Wed Feb 02, 2005 1:49 pm
Posts: 4
Hi People, Sorry by my bad english..

I have a problem with de one-to-many mapping. Take a look:

<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="DataAttrib"
table="DATAATTRIB"
dynamic-update="false"
dynamic-insert="false"
>

<composite-id>
<key-property type="java.lang.String" name="cdData" column="CDDATA" l ength="18" />
<key-property type="java.lang.Long" name="cdAttrib" column="CDSECTIONATTRIB" />
</composite-id>

<property
name="nmString"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="NMSTRING"
/>

<property
name="vlFloat"
type="java.lang.Float"
update="true"
insert="true"
access="property"
column="VLFLOAT"
/>

<property
name="dtDate"
type="java.util.Date"
update="true"
insert="true"
access="property"
column="DTDATE"
/>

<property
name="dsMemo"
type="text"
update="true"
insert="true"
access="property"
column="DSMEMO"
/>

<set
name="myDataAttribValue"
table="FRDATAATTRIBVALUE"
lazy="false"
inverse="true"
cascade="none"
sort="unsorted"
>

<key>
<column name="CDFORMDATA" />
<column name="CDNATTRIB"/>
<column name="CDVALUE"/>
</key>

<one-to-many
class="FRDataAttribValue"
/>
</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-FRFormDataAttribute.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>

I have a problem in this mapping because the composite keys in the one-to-many mapping. When i execute my server jBoss, I receive the message error:

net.sf.hibernate.MappingException: collection foreign key mapping has wrong number of columns: DataAttrib.myDataAttribValue type: DataAttrib

somebody can help me ??

Thanks ...
Jeferson...


Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 10:18 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
well ... as the message said, the numbers of columns are not correct ...

you need on both sides the same number of columns ... in compositeID of "FRDataAttribValue" and in your "Set"

gtx
curio


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 10, 2005 10:49 am 
Newbie

Joined: Wed Feb 02, 2005 1:49 pm
Posts: 4
curio, the mapping of the class FRDataAttribValue is:

<composite-id>
<key-property type="java.lang.String" name="cdFormData" column="CDFORMDATA" length="18" />
<key-property type="java.lang.Long" name="cdSectionAttrib" column="CDSECTIONATTRIB" />
<key-property type="java.lang.Long" name="cdValue" column="CDVALUE" />
</composite-id>

This is equal of the mapping in the set attribute in the previous mapping ...

You have other ideia for solution this problem ???

Thanks..
Jeferson..


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.