Hi,
I get an IllegalArgumentException calling the getter or setter method with the following <many-to-one> relationship property:
Code:
<class name="PickList">
<many-to-one name="collectionPickList"
access="property"
class="CollectionPickList"
column="ID_EMPFAENGER"
property-ref="shipmentId"/>
</class>
The class PickList contains the following methods:
Code:
class PickList {
...
public CollectionPickList getCollectionPickList() {...}
public boolean isCollectionPickList() {...}
public void setCollectionPickList(CollectionPickList collectionPickList) {...}
}
When I try to save an instance of PickList, I get the following errors:
IllegalArgumentException occurred while calling setter of com.rhenus.rml.businessclasses.warehouse.helas.PickList.collectionPickList
Caused by: java.lang.IllegalArgumentException: argument type mismatch
When I try to select an instance of PickList I get the following error messages:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.rhenus.rml.businessclasses.warehouse.helas.BasePickList.shipmentId
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
The problem here is, that Hibernate assumes the property "collectionPickList" to be of type "java.lang.Boolean" because of the method "isCollectionPickList()". When I change the access of the <many-to-one> property to "field" it works:
Code:
<class name="PickList">
<many-to-one name="collectionPickList"
access="field"
class="CollectionPickList"
column="ID_EMPFAENGER"
property-ref="shipmentId"/>
</class>
Hibernate obviousely doesn't take the "class" property into account in this case. This may be considered as a bug!
Best regards
Thomas