-->
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.  [ 1 post ] 
Author Message
 Post subject: Cannot key a map collection by its primary key?
PostPosted: Mon Mar 21, 2005 9:36 am 
Regular
Regular

Joined: Fri Feb 13, 2004 10:02 pm
Posts: 90
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.