Mapping collection of entities with same name and notnull constraints from two different entities results in duplicate property mapping of Backref

Description

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.

Environment

None

Activity

Show:
Andreas Joseph Krogh
November 16, 2012, 6:35 PM

I'm still seeing this in 4.1.8 with the following uni-directional mappings:

User

Person

EntityEmailAddress doesn't have recipient_id mapped as colum.

Error is:

I'll work on a repcoducable test-case if interessted.

Andreas Joseph Krogh
November 16, 2012, 10:37 PM

Can someone re-open this issue so I can attach an example showing this isn't working?

Andreas Joseph Krogh
November 16, 2012, 11:28 PM

There are two issues:

Issue 1; The field-mapping has the same name:

Fails with:
Caused by: org.hibernate.MappingException: Duplicate property mapping of _emailAddresses_recipient_idBackref found in org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.ondemand.OneToManyHHH5836Test$EmailAddress

Issue 2: The field-mapping has different name:

Fails with:
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: org.hibernate.test.annotations.derivedidentities.e1.b.specjmapid.ondemand.OneToManyHHH5836Test$EmailAddress column: recipient_id (should be mapped with insert="false" update="false")

Brett Meyer
November 19, 2012, 5:29 PM

, this issue has already been closed and released in 4.1.8. If there is an additional issue, can you please open a new ticket? Thanks!

Andreas Joseph Krogh
November 19, 2012, 5:54 PM

Ok, new issue created here:

Assignee

Brett Meyer

Reporter

milan brich

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure