Hi,
I am responsible for the Eclipse EMF Teneo project, I run Hibernate with a testsuite of 500+ testcases. I am upgrading to Hibernate 4.2.7SP1. I noticed that for some of my testcases I get the exception below.
This seems to happen when I have a many-to-many mapping with unique="true", with unique="false" it does not happen. (see mapping below in the post)
The many-to-many with unique=true approach is outlined here in the docs:
http://docs.jboss.org/hibernate/orm/4.2/manual/en-US/html_single/#assoc-unidirectional-join-12m
When looking at the stacktrace I get to this call in the Cascade class line 429:
cascadeProperty(
parent,
iter.next(),
elemType,
style,
null,
anything,
isCascadeDeleteEnabled
);
As you can see a null is passed for the propertyName parameter. This seems to result in the exception below.
Not sure if this is a known issue or if I should change my mapping (mapping shown below).
Code:
org.hibernate.HibernateException: Unable to resolve property: null
at org.hibernate.tuple.entity.EntityMetamodel.getPropertyIndex(EntityMetamodel.java:791)
at org.hibernate.persister.entity.AbstractEntityPersister.getPropertyIndex(AbstractEntityPersister.java:2397)
at org.hibernate.engine.spi.EntityEntry.getLoadedValue(EntityEntry.java:280)
at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:235)
at org.hibernate.engine.internal.Cascade.cascadeCollectionElements(Cascade.java:429)
at org.hibernate.engine.internal.Cascade.cascadeCollection(Cascade.java:369)
at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:345)
at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:208)
at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:165)
Code:
<list name="address" table="`ABC`" lazy="true" cascade="all,delete-orphan">
<key foreign-key="EMPLOYEE_ADDRESS_KEY" update="true">
<column name="`EMPLOYEE_ADDR_ID`" unique="false"/>
</key>
<list-index column="`PERSON_ADDRESS_IDX`"/>
<many-to-many entity-name="Address" unique="true" foreign-key="EMPLOYEE_ADDRESS"/>
</list>