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

Frido van Orden (JIRA) noreply at atlassian.com
Fri Nov 14 08:58:23 EST 2008


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

Frido van Orden commented on HHH-572:
-------------------------------------

The workaround with a formula does not work if the many-to-one inside the composite-element is composite itself. In that case, a NPE occurs:

java.lang.NullPointerException
	at org.hibernate.util.StringHelper.qualify(StringHelper.java:287)
	at org.hibernate.util.StringHelper.qualify(StringHelper.java:301)
	at org.hibernate.loader.JoinWalker.walkCompositeElementTree(JoinWalker.java:522)
	at org.hibernate.loader.JoinWalker.walkCollectionTree(JoinWalker.java:333)
	at org.hibernate.loader.JoinWalker.walkCollectionTree(JoinWalker.java:278)
	at org.hibernate.loader.collection.BasicCollectionJoinWalker.<init>(BasicCollectionJoinWalker.java:70)
	at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:76)
	at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:63)
	at org.hibernate.loader.collection.BasicCollectionLoader.<init>(BasicCollectionLoader.java:54)
	at org.hibernate.loader.collection.BatchingCollectionInitializer.createBatchingCollectionInitializer(BatchingCollectionInitializer.java:115)
	at org.hibernate.persister.collection.BasicCollectionPersister.createCollectionInitializer(BasicCollectionPersister.java:320)
	at org.hibernate.persister.collection.AbstractCollectionPersister.postInstantiate(AbstractCollectionPersister.java:563)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:326)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)



> 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