[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5836) Mapping collection of entities with same name and notnull constraints from two different entities results in duplicate property mapping of Backref

Milan Brich (JIRA) noreply at atlassian.com
Wed Jan 12 12:01:05 EST 2011


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

Milan Brich commented on HHH-5836:
----------------------------------

Problem looks like is in CollectionBinder class row 740:

String entityName = oneToMany.getReferencedEntityName();
PersistentClass referenced = mappings.getClass( entityName );
Backref prop = new Backref();
prop.setName( '_' + fkJoinColumns[0].getPropertyName() + "Backref" );

fkJoinColumns[0].getPropertyName() is same for both collections, maybe distingushing with fkJoinColumns[0].getLogicalColumnName() would resolve it.

> Mapping collection of entities with same name and notnull constraints from two different entities results in duplicate property mapping of Backref
> --------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-5836
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5836
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: annotations
>    Affects Versions: 3.5.6
>            Reporter: Milan Brich
>         Attachments: hibernate-backref-bug.zip
>
>
> When two entities have OneToMany relationship to third entity and the collection name is same in both entities and nullable is set to false. Then exception written below is thrown.
> Caused by: org.hibernate.MappingException: Duplicate property mapping of _parentsBackref found in cz.csas.persistence.test.Parent
> 	at org.hibernate.mapping.PersistentClass.checkPropertyDuplication(PersistentClass.java:483)
> 	at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:473)
> 	at org.hibernate.mapping.RootClass.validate(RootClass.java:236)
> 	at org.hibernate.cfg.Configuration.validate(Configuration.java:1193)
> 	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1378)
> 	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
> 	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:892)
> 	... 58 more
> Attached annotated entities.

-- 
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