-->
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.  [ 2 posts ] 
Author Message
 Post subject: Why INSERT = false UPDATE=false ?? I need insert!!
PostPosted: Wed Jul 13, 2005 3:05 am 
Newbie

Joined: Tue Jul 12, 2005 9:00 am
Posts: 2
Hello, I have a problem with a especial association many-to-one:

the PK of both tables is composed by two id's :

TABLE A:
idA (PK) (FK)
idB (PK)
-------------
name
surname
idC (FK)



TABLE B:
idA (PK)
idC (PK)
--------------
general_info




the problem seems to be: I have divided the FK (from TABLE A to TABLE B) :
    idA is FK to the TABLE B (and part of the PK of this TABLE)
    idC is only FK to the TABLE B.



the association is mapped in TABLE A as follows:
Code:
<many-to-one
        name="tableB"
        class="TableB"
        not-null="true"   
    >
    <column name="idA" />
    <column name="idC" />   
  </many-to-one>


AND the PK of TABLE A is mapped just like that:

Code:
<composite-id name="comp_id" class="TableAPK">
       <key-property
            name="idA"
            column="idA"
            type="java.lang.Long"
            length="9"
        />
        <key-property
            name="idB"
            column="idB"
            type="java.lang.Long"
            length="9"
        />
    </composite-id>   




When Hibernate read the mapping files throws a Exception :

Code:
Caused by: net.sf.hibernate.MappingException: Repeated column in mapping for class TableA should be mapped with insert="false" update="false": idA   at net.sf.hibernate.persister.AbstractEntityPersister.checkColumnDuplication(AbstractEntityPersister.java:1015)
   at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:799)
   at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:42)
   at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:137)
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)





With insert= false and update = false I cannot insert the FK to the TABLE B. AnyOne Knows Who I can solve this problem!!!????

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 13, 2005 2:29 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
I don't know the solution, necessarily, but what this error is saying is that you have two properties (composite-id and many-to-one) mapped to the same column in the table (idA). Hibernate needs to know which property to use to set/change that column.

So one of them needs to have update="false" insert="false" so that Hibernate knows to use the other property when inserting/updating the record.

Whether that's all you need to change, I don't know. I haven't mapped a relationship like that.


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