views:

299

answers:

3

Out of the blue I started getting “IllegalArgumentException: argument type mismatch” in hibernate. The hibernate entity was working for quite some time and svn logs confirm the code to be intact.

What might be the case?
Here’s part of the exception

Jan 16, 2010 10:47:09 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalArgumentException: argument type mismatch
    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:597)
    at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
    at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3566)
    at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
    at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:854)
    at org.hibernate.loader.Loader.doQuery(Loader.java:729)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
    at org.hibernate.loader.Loader.doList(Loader.java:2220)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
    at org.hibernate.loader.Loader.list(Loader.java:2099)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
    at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
    at org.springframework.orm.hibernate3.HibernateTemplate$30.doInHibernate(HibernateTemplate.java:930)
    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
    at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:921)
+1  A: 

I've heard of this happening due to underlying database field changes (such as date to timestamp). It might be worth reverting the database changes if you're able and testing it, or checking the .hbm or annotations as Sands suggested.

Kaleb Brasee
@Kaleb u r right. Addition of this code to the hbm created this error `<set inverse="true" name="qs" sort="unsorted" lazy="false"> <key> <column name="q_id" not-null="false"/> </key> <one-to-many class="com.comp.domain.Q" /> </set>` Do u have any idea why it might be?
Quintin Par
+1  A: 

Translation: Hibernate provides an argument of wrong type when trying to invoke a setter method.

My first step would be to find out which setter that is (for instance by debugging the application in eclipse, setting an exception break point, and inspecting the stack variables once the breakpoint is reached).

Edit: What is the signature of the setter for the mapped property qs? It should take a Set<Q>.

meriton
You are right. It was an erroneous type. List instead of Set
Quintin Par
+1  A: 

So, you modified an hibernate mapping file without modifying the Entity? I guess that the qs property was already there then. But is it a java.util.Set (as you used a <set> to map your collection)?

Pascal Thivent