[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-572) Repeated columns rejected in a collection of composite elements

michael harris (JIRA) noreply at atlassian.com
Sat May 2 17:44:18 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-572?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33071#action_33071 ] 

michael harris commented on HHH-572:
------------------------------------

Yes this is an issue for me as well.  It seems there is no support for a one to many join with shared composite key elements, and with this bug, I can't map the join table as a composite element.  The lifecycle semantics would be nice here.  My only option is to map a one-to-many on an entity for the join table, and then a unique many-to-many on the join table to the child.  which is a pain.  

I feel this is an important issue.  I feel having an entity that can be attached to any number of parents with shared composite keys is not that exotic of a use case.  Support for this would save a bunch of time.

> Repeated columns rejected in a collection of composite elements
> ---------------------------------------------------------------
>
>                 Key: HHH-572
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-572
>             Project: Hibernate Core
>          Issue Type: Bug
>    Affects Versions: 3.0.5
>         Environment: JRE 1.4.2_08
>            Reporter: Emmanuel Bourg
>            Assignee: Gavin King
>            Priority: Minor
>
> Repeating a column in a collection of composite elements triggers an error when the mapping is parsed, even if the property with the repeated column has the insert and update attributes set to false:
>     <set name="children" table="CHILDREN">
>       <key column="PARENT_ID"/>
>       <composite-element class="Child">
>         <property name="parentId" column="PARENT_ID" insert="false" update="false" />
>       </composite-element>
>     </set>
> or
>     <set name="roles" table="ROLE">
>       <key column="PARENT_ID"/>
>       <composite-element class="Role">
>         <many-to-one name="child" class="Child"/>
>         <property name="childId" column="CHILD_ID" insert="false" update="false" />
>       </composite-element>
>     </set>
> Hibernate throws this exception:
> org.hibernate.MappingException: Repeated column in mapping for collection: Parent.children column: PARENT_ID
>     at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:275)
>     at org.hibernate.mapping.Collection.checkColumnDuplication(Collection.java:298)
>     at org.hibernate.mapping.Collection.validate(Collection.java:255)
>     at org.hibernate.mapping.Set.validate(Set.java:19)
>     at org.hibernate.cfg.Configuration.validate(Configuration.java:817)
>     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:976)
> a workaround is to use a formula:
>     <set name="children" table="CHILDREN">
>       <key column="PARENT_ID"/>
>       <composite-element class="Child">
>         <property name="parentId" formula="PARENT_ID"/>
>       </composite-element>
>     </set>
> This works fine with the fix for HHH-539

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list