I use a collection of components for a many-to-many association, and Hibernate throws MappingException when I query it using criteria. The code is as following.
But Hibernate works correctly when I use HQL(from PatentApplyForm paf join paf.inventorDatas ids) to query!
And If I change the association to general many-to-many (without components) association, the criteria works fine!
The one I can't do is simply many-to-many with components using criteria query!
Hibernate version: 216
Mapping documents:
<class name="PatentApplyForm" table="...">
...
<set name="inventorDatas" table="...">
<key column="DCNO"/>
<composite-element class="InventorData">
<many-to-one name="inventorPersonal" class="InventorPersonal" column="INVER_ID" />
<property name="reqerYn" column="REQER_YN" />
</composite-element>
</set>
</class>
Code:
Criteria criteria = session.createCriteria(PatentApplyForm.class);
criteria.createAlias("inventorDatas", "ids"); // throw MappingException...
Full stack trace of exception:
net.sf.hibernate.MappingException: collection was not an association: tw.gov.nsc.rp.patent.PatentApplyForm.inventorDatas
at net.sf.hibernate.type.PersistentCollectionType.getAssociatedClass(PersistentCollectionType.java:206)
at net.sf.hibernate.impl.CriteriaImpl.getClassForPath(CriteriaImpl.java:345)
at net.sf.hibernate.impl.CriteriaImpl.createAlias(CriteriaImpl.java:302)
at net.sf.hibernate.impl.CriteriaImpl.createAlias(CriteriaImpl.java:276)
...
|