Hibernate version:
3.0 CVS 03-21-2005
Mapping documents:
EntityRoleType
Code:
<hibernate-mapping>
<class name="com.llic.domain.EntityRoleType" table="DomEntityRoleType">
<meta attribute="implement-equals">true</meta>
<meta attribute="generated-class">com.llic.domain.base.EntityRoleTypeBase</meta>
<id name="id" column="entityRoleTypeId" type="java.lang.Long">
<meta attribute="use-in-equals">true</meta>
<generator class="native" />
</id>
<property name="code" column="name" type="string" not-null="true" length="20"/>
<property name="description" column="description" type="string" not-null="true" length="254"/>
<!-- sub types by code -->
<map name="subTypeCodeMap" table="DomEntityRoleSubType">
<!-- foreign key -->
<key column="entityRoleTypeId"/>
<!-- mapping key -->
<map-key type="string">
<column name="code"/>
</map-key>
<one-to-many class="com.llic.domain.EntityRoleSubType"/>
</map>
<!-- sub types by id -->
<map name="subTypeIdMap" table="DomEntityRoleSubType">
<!-- foreign key -->
<key column="entityRoleTypeId"/>
<!-- mapping key -->
<map-key type="java.lang.Long">
<column name="entityRoleSubTypeId"/>
</map-key>
<one-to-many class="com.llic.domain.EntityRoleSubType"/>
</map>
</class>
</hibernate-mapping>
EntityRoleSubType
Code:
<hibernate-mapping>
<class name="com.llic.domain.EntityRoleSubType" table="DomEntityRoleSubType">
<meta attribute="implement-equals">true</meta>
<meta attribute="generated-class">com.llic.domain.base.EntityRoleSubTypeBase</meta>
<id name="id" column="entityRoleSubTypeId" type="java.lang.Long">
<meta attribute="use-in-equals">true</meta>
<generator class="native" />
</id>
<property name="code" column="name" type="string" not-null="true" length="20"/>
<property name="description" column="description" type="string" not-null="true" length="254"/>
<!-- entity types by code. inverse="true" maps the fk to the current table-->
<map name="entityTypeCodeMap" table="DomEntityRoleType" inverse="true">
<!-- foreign key -->
<key column="entityRoleTypeId" />
<!-- mapping key -->
<map-key type="string" column="code"/>
<one-to-many class="com.llic.domain.EntityRoleSubType"/>
</map>
<!-- sub types by id -->
<map name="entityTypeIdMap" table="DomEntityRoleType" inverse="true">
<!-- foreign key -->
<key column="entityRoleTypeId"/>
<!-- mapping key -->
<map-key type="java.lang.Long" column="entityRoleTypeId"/>
<one-to-many class="com.llic.domain.EntityRoleSubType"/>
</map>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
Caused by: org.hibernate.MappingException: Repeated column in mapping for collection: com.llic.domain.EntityRoleSubType.entityTypeIdMap column: entityRoleTypeId
at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:265)
at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:280)
at org.hibernate.mapping.Collection.validate(Collection.java:245)
at org.hibernate.mapping.IndexedCollection.validate(IndexedCollection.java:67)
at org.hibernate.cfg.Configuration.validate(Configuration.java:816)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1048)
Name and version of the database you are using:
DB2 UDB 8.2
Debug level Hibernate log excerpt:
See Above
It appears that I cannot create a map that is keyed by the mapped objects identity. Is the the expected behavior, and if so, how do I get around this?