-->
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 exception
PostPosted: Tue Sep 13, 2005 9:10 pm 
Beginner
Beginner

Joined: Thu Jun 09, 2005 2:33 pm
Posts: 30
I realize this topic has been posted before, and I've tried to solve this be referencing other threads, but still feel like I need another eye to look at it. Anyway, the error I'm getting is: org.hibernate.MappingException: Foreign key (FKB95A8278CD821C6C:images [elt])) must have same number of columns as the referenced primary key (images [propertyId,elt])

Here are my 2 mapping files:

PropertyInfo.hbm.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
   
<hibernate-mapping>
   <class
        name="com.realestate.model.PropertyInfo"
        table="property_listings">

        <id
            name="id"
            column="propertyId"
            type="long"
            unsaved-value="0">
            <generator class="native"/>
        </id>
       
        <property name="listingType"/>
        <property name="propertyType"/>
        <property name="firstName"/>
        <property name="lastName"/>
        <property name="propertyAddress"/>
        <property name="propertyCounty"/>
        <property name="propertyCity"/>
        <property name="askingPrice"/>
        <property name="email"/>
        <property name="dayareacode"/>
        <property name="dphone1"/>
        <property name="dphone2"/>
        <property name="description"/>
        <property name="numBedrooms"/>
        <property name="numBaths"/>
        <property name="postDate"/>
       
        <set name="images" table="images" cascade="save-update" inverse="true">
            <key column="propertyId"/>         
            <one-to-many class="com.realestate.model.Image"/>
        </set>
       
   </class>
   
</hibernate-mapping>


Image.hbm.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
   
<hibernate-mapping>
   <class name="com.realestate.model.Image" table="images">
       
        <id
            name="id"
            column="id"
            type="long"
            unsaved-value="0">
            <generator class="native"/>
        </id>
       
        <property name="image"/>
        <property name="name"/>
       
        <many-to-one
           name="info"
           column="propertyId"
           class="com.realestate.model.PropertyInfo"/>

       
   </class>
   
</hibernate-mapping>


Any insight as to what I have to change would be greatly appreciated. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 9:38 pm 
Beginner
Beginner

Joined: Thu Jun 09, 2005 2:33 pm
Posts: 30
Never mind. I figured it out. Very dumb mistake that had nothing to do with the hbm's themselves ;)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 13, 2005 10:34 am 
Newbie

Joined: Wed Oct 12, 2005 10:56 am
Posts: 6
Could you describe the solution anyway. I have been breaking my head over a many-to-one for some time now. May be i had the same silly issue. thx


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.