We have a composite key where the same column (ccid) is duplicated in three <many-to-one> elements:
Code:
<composite-id name="comp_id" class="aPackage.MtncpPK">
<meta attribute="field-description">
@hibernate.id
generator-class="assigned"
</meta>
<key-property name="mode" column="mode" type="java.lang.String" length="4"/>
<!-- bi-directional many-to-one association to Mtcep -->
<key-many-to-one name="mtcepByCcidAndNcell"
class="aPackage.Mtcep">
<column name="ccid"/>
<column name="ncell" />
</key-many-to-one>
<!-- bi-directional many-to-one association to Mtcep -->
<key-many-to-one name="mtcepByCcidAndCell"
class="aPackage.Mtcep">
<column name="ccid"/>
<column name="cell" />
</key-many-to-one>
<!-- bi-directional many-to-one association to SwitchView -->
<key-many-to-one name="switchView"
class="aPackage.SwitchView">
<column name="ccid"/>
</key-many-to-one>
</composite-id>
Naturally this causes a mapping error (see below) since we have to identify the dominant property by setting the others with
Code:
update="false" insert="false"
.
Problem is, as per the DTD, the <key-many-to-one> element does not allow
Code:
update="false" insert="false"
. In that case, how exactly should we specify the dominant element?
Thought I had found a solution to my problem in this thread:
http://forum.hibernate.org/viewtopic.php?t=926346, but there is no solution for a <key-many-to-one> element.
mapping error
--------------
Code:
Caused by: java.lang.RuntimeException: Exception building SessionFactory: Repeated column in mapping for class se.ericsson.lmc.ccl.model.dto.temp_lmcfrob_hbm.hibernate.MtocpExt should be mapped with insert="false" update="false": ccid
at aPackage.(HibernateUtil.java:29)
... 37 more
Caused by: net.sf.hibernate.MappingException: Repeated column in mapping for class se.ericsson.lmc.ccl.model.dto.temp_lmcfrob_hbm.hibernate.Mtncp should be mapped with insert="false" update="false": ccid
at net.sf.hibernate.persister.AbstractEntityPersister.checkColumnDuplication(AbstractEntityPersister.java:1000)
at net.sf.hibernate.persister.EntityPersister.(EntityPersister.java:757)
at net.sf.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:41)
at net.sf.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:137)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:739)
at (HibernateUtil.java:25)
... 37 more
Thanking you all in advance for the help!