-->
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.  [ 4 posts ] 
Author Message
 Post subject: IllegalArgumentException occurred calling getter...
PostPosted: Wed Oct 26, 2005 7:23 am 
Beginner
Beginner

Joined: Wed Oct 12, 2005 8:52 am
Posts: 23
Hello,

I have a situation where I am querying a table (USER) with a simple SQL "select u from User u where u.userID=1". USER has a one-to-many rel with COMMENTS and ITEM has a one-to-many rel with COMMENTS.

My program is kinda generic. I need to load all parents first then the child. It check whether the object is of entity type or collection type. If it is an entity is add the object in a list and if it is a collection it will check whether the child has any other parents before adding them all to the list. The list of objects is then replicated in another database.

For this particular case USER is the target object which will be saved and COMMENTS is of collection type and ITEM is entity of course.

The problem that i get "
Quote:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.hibernate.Comment.Item
"

Anyone has an idea what can cause this type of prob?
Thanks.

Hibernate version:
3

Mapping documents:
USER:
<!-- bi-directional one-to-many association to Comment -->
<set
name="comments"
lazy="true"
inverse="true"
cascade="all"
>
<column name="FROM_USER_ID" />
</key>
<one-to-many
class="com.hibernate.Comment"
/>
</set>

COMMENT:
<!-- bi-directional many-to-one association to Item -->
<many-to-one
name="Item"
class="com.hibernate.Item"
not-null="true"
fetch="join"
>
<column name="ITEM_ID" />
</many-to-one>
<!-- bi-directional many-to-one association to User -->
<many-to-one
name="user"
class="com.hibernate.User"
not-null="true"
fetch="join"
>
<column name="FROM_USER_ID" />
</many-to-one>

Full stack trace of any exception that occurs:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.hibernate.Comment.Item
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:119)
at org.hibernate.tuple.AbstractTuplizer.getPropertyValue(AbstractTuplizer.java:195)
at org.hibernate.tuple.AbstractTuplizer.getPropertyValue(AbstractTuplizer.java:199)
at org.hibernate.persister.entity.BasicEntityPersister.getPropertyValue(BasicEntityPersister.java:2939)
at com.acc.testdatamgt.DependentObjects.getParentList(DependentObjects.java:68)
at com.acc.testdatamgt.DependentObjects.extract(DependentObjects.java:48)
at com.acc.testdatamgt.DependentObjects.getParentList(DependentObjects.java:135)
at com.acc.testdatamgt.DependentObjects.extract(DependentObjects.java:48)
at com.acc.testdatamgt.DBSubset.main(DBSubset.java:141)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:105)
... 8 more
Exception in thread "main" KOP:[com.hibernate.Comment@3a1ec6[commentId=2]]

(property.BasicPropertyAccessor 115 ) IllegalArgumentException in class: com.hibernate.Comment, getter method of property: Item

Name and version of the database you are using:
HSQLDB


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 9:05 am 
Beginner
Beginner

Joined: Tue Aug 23, 2005 3:52 pm
Posts: 26
this is straight from the java doc of the Method.invoke() that is being called by at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get


"@exception IllegalArgumentException if the method is an
* instance method and the specified object argument
* is not an instance of the class or interface
* declaring the underlying method (or of a subclass
* or implementor thereof); if the number of actual
* and formal parameters differ; if an unwrapping
* conversion for primitive arguments fails; or if,
* after possible unwrapping, a parameter value
* cannot be converted to the corresponding formal
* parameter type by a method invocation conversion."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 9:48 am 
Regular
Regular

Joined: Mon Aug 29, 2005 9:46 am
Posts: 102
How is your set "comments" declared on your bean? Make sure it's a "Set" and in the declaration you have:

Code:
private Set comments = new HashSet();


is that how it is?

_________________
Don't forget to rate if the post helped!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 27, 2005 1:47 am 
Beginner
Beginner

Joined: Wed Oct 12, 2005 8:52 am
Posts: 23
It's:

Code:
private Set comments;


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

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.