-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: IllegalArgumentException with many-to-one property
PostPosted: Wed Apr 04, 2012 7:57 am 
Newbie

Joined: Thu Aug 25, 2011 4:52 am
Posts: 5
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.