-->
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.  [ 6 posts ] 
Author Message
 Post subject: IllegalArgumentException saving POJO with inheritance
PostPosted: Sun Apr 10, 2005 8:33 pm 
Newbie

Joined: Sun Apr 10, 2005 2:20 am
Posts: 15
So I modified my little graph model and now I have, in addition to Parent, Link and Node, two subclasses of Node: DataNode and ExecutableNode.

When persisting Parent containing aLink and anExecutableNode and aDataNode, I get the following exception:

Code:
- IllegalArgumentException in class: ExecutableNode, getter method of property: executions


After some debugging I found out that SaveOrUpdateEvent object that is created in org.hibernate.impl.SessionImpl line 415 contains:
Code:
SaveOrUpdateEvent
{
   entity = aDataNode
   entityName = "ExecutableNode"
   entry = null
   object = aDataNode
   requestId = null
   sessionImpl = aSessionImpl
}


As you can see entity and entityName refer to the same instance of DataNode. However, the entityName refers to the ExecutableNode class name. Down at BasicPropertyAccessor$BasicGetter.get(Object) line 119 I get the above exception because Hibernate is trying to get a property from class ExecutableNode but it is passing a DataNode instance as the target. It seems to mixing up subclass instances of Node.

FYI: I have one mapping file per class and I am using <subclass> with a discriminator for each of the two subclasses.

Any ideas what is going on here?

-- yuri

Here is the full exception:
Code:
- IllegalArgumentException in class: com.metaserver.engine.process.instance.ActivityInstance, getter method of property: activityExecutions
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of ExecutableNode.executions
   at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:119)
   at org.hibernate.tuple.AbstractTuplizer.getPropertyValue(AbstractTuplizer.java:195)
   at org.hibernate.persister.entity.BasicEntityPersister.getPropertyValue(BasicEntityPersister.java:2937)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:817)
   at org.hibernate.event.def.AbstractSaveEventListener.cascadeBeforeSave(AbstractSaveEventListener.java:330)
   at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:212)
   at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:158)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
   at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:416)
   at org.hibernate.engine.Cascades$5.cascade(Cascades.java:153)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:721)
   at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:860)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:739)
   at org.hibernate.engine.Cascades.cascade(Cascades.java:817)
   at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:361)
   at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:263)
   at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:158)
   at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
   at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
   at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
   at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:429)
   at org.hibernate.impl.SessionImpl.save(SessionImpl.java:424)
   at Main.createGraph(Main.java:446)
   at Main.main(Main.java:374)
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)
   ... 30 more


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 10, 2005 8:58 pm 
Newbie

Joined: Sun Apr 10, 2005 2:20 am
Posts: 15
Ok, I guess going through my problem and writting it down made me realize what the problem was:
Code:
   <set name="nodes" inverse="true" cascade="all-delete-orphan">
         <key column="parent"/>
         <one-to-many class="ExecutableNode"/>
   </set>


Instead of:
Code:
   <set name="nodes" inverse="true" cascade="all-delete-orphan">
         <key column="parent"/>
         <one-to-many class="Node"/>
   </set>


I fixed it and it worked fine. I guess the only trouble was figuring out the real problem when I hit the exception.

thanks,

-- yuri


Top
 Profile  
 
 Post subject: Similar problem.
PostPosted: Wed Oct 26, 2005 8:04 pm 
Newbie

Joined: Wed Oct 26, 2005 7:56 pm
Posts: 1
I am getting the same exception, except I don't see the problem. I am using an associated mapping - unidirectional one-to-one from object Listing to object Areas.

Code:
<class name="Listing" table="Listings">
...
<many-to-one name="area"
   class="Areas"
   column="AREA"
   unique="true" />
...
</class>

<class name="Areas" table="Areas">
   <id name="id" column="areaId" type="java.lang.Integer">
      <generator class="native"/>
   </id>
...
</class>


The exception I am getting when I try to read a Listing object is:
Code:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.itspd.hibernate.AbstractAreas.id


Am I overlooking something?

Thanks in advance,
Paul


Top
 Profile  
 
 Post subject: Same problem
PostPosted: Sun Jan 29, 2006 4:28 pm 
Newbie

Joined: Fri Dec 30, 2005 5:25 am
Posts: 13
I am having a similar problem, here's my exception... Any ideas?
I'm using Hibernate 3.1, HSQLDB and JDK 1.5.

Thanks!

Nicolas

Code:
org.springframework.webflow.ActionExecutionException: Exception thrown executing action 'flows.ProjectAction@cac877' in state 'gatherToolsInfo' of flow 'registration'; nested exception is org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException
occurred calling getter of domain.AbstractDomainEntity.id; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of domain.AbstractDomainEntity.id
org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred calling getter of domain.AbstractDomainEntity.id; nested exception is org.hiber
nate.PropertyAccessException: IllegalArgumentException occurred calling getter of domain.AbstractDomainEntity.id
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of domain.AbstractDomainEntity.id
        at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:1
71)
        at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)
....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 12:18 am 
Newbie

Joined: Tue Jan 31, 2006 11:04 pm
Posts: 2
Hi All,

Any luck with IllegalArgumentException exception when saving the subclass. I am running into the same error, and have no idea what's wrong.

Thanks.

The error trace is

org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.peye.model.ContactLensHistory.answerType
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:119)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.getForInsert(BasicPropertyAccessor.java:124)
at org.hibernate.tuple.AbstractTuplizer.getPropertyValuesToInsert(AbstractTuplizer.java:189)
at org.hibernate.tuple.PojoTuplizer.getPropertyValuesToInsert(PojoTuplizer.java:194)
at org.hibernate.persister.entity.BasicEntityPersister.getPropertyValuesToInsert(BasicEntityPersister.java:3005)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:216)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
::::::::::
::::::::::::::::
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@952527
at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 16, 2006 3:54 am 
Newbie

Joined: Fri Dec 30, 2005 5:25 am
Posts: 13
The problem I had had actually nothing to do with the class he was complaining about. This class was a superclass from all my "Domain" object.

What really happened (after some debugging I finally found out), is that at the time the real object (which a subclass of the Abstract... it was complaining about) could not be correctly retrieved in the application logic (it was a Spring MVC form binding issue).

I would have loved to get an error message like: "Hey idiot, why are trying to call get in a object which is not even a subclass of the Abstract..., I can't do that...". Of course, I'd check your getter/setters (you can have them auto-generated by your IDE) and your inheritance tree.

Just my 2 cents.

Good luck


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.