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