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!