-->
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.  [ 6 posts ] 
Author Message
 Post subject: Two times <key-many-to-one/> in <composite-id/>
PostPosted: Fri Dec 12, 2003 9:53 am 
Beginner
Beginner

Joined: Thu Dec 11, 2003 9:54 am
Posts: 25
I got troubles with next mapping file:

Code:
<?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>
<!--
    Created by Middlegen Hibernate plugin

    http://boss.bekk.no/boss/middlegen/
    http://hibernate.sourceforge.net/
-->

<class
    name="First"
    table="FIRST"
>

    <composite-id name="comp_id" class="FirstPK">
        <key-property
            name="Id"
            column="ID"
            type="java.math.BigDecimal"
            length="22"
        />
        <!-- bi-directional many-to-one association to Second -->
        <key-many-to-one
           name="second"
         class="Second"
          column="TYPEE"
        />
        <!-- bi-directional many-to-one association to Third -->
        <key-many-to-one
           name="third"
         class="Third"
          column="TYPEE"
        />
    </composite-id>

    <!-- associations -->

</class>
</hibernate-mapping>


the error is next:

HibernateException: net.sf.hibernate.MappingException: Repeated column in mapping for class First should be mapped with insert="false" update="false": TYPEE

How I can mapped it ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 10:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
You are referring to the same column more than once (as stated in the exception) - thus you have to tell Hibernate which property should be the dominant one. There can't be more than one property that tells what the value should be...because how should hibernate know which one to save if the properties somehow returned different results ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 10:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
....so, you should just do what the exception says:

Mark the non-dominant properties as insert="false" update="false"

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 10:54 am 
Beginner
Beginner

Joined: Thu Dec 11, 2003 9:54 am
Posts: 25
max wrote:
....so, you should just do what the exception says:

Mark the non-dominant properties as insert="false" update="false"


I'v tried, but without success...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 7:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Post an example that fails (with a main method!)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 6:07 pm 
Newbie

Joined: Wed Aug 27, 2003 2:53 pm
Posts: 14
Location: New Jersey
I noticed this problem myself when trying to deal with mappings that use the same column more than once. The problem he is having is that the <key-many-to-one> tag does NOT allow insert="false" update="false".

Luckily, my scenario has the duplicated column between a <key-many-to-one> and <many-to-one> tag so I could put the insert="false" update="false" stuff on the <many-to-one>.

Hope this helps clarify the problem, if not the solution.

Sarah


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