java.lang.IllegalArgumentException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • As I use integer-type primary keys in the db I wanted to use the increment-generator to keep them unique. While trying to dump a test-object to the db, I got the following error: 15.08.2003 11:32:26 net.sf.hibernate.util.ReflectHelper$Setter set SCHWERWIEGEND: IllegalArgumentException in class: de.fzi.dbs.cwb.Customer, setter method of property: cid 15.08.2003 11:32:26 net.sf.hibernate.util.ReflectHelper$Setter set SCHWERWIEGEND: expected type: int, actual value: java.lang.Long net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of de.fzi.dbs.cwb.Customer.cid 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:324) at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45) at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:251) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:674) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605) (...) rethrown as net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of de.fzi.dbs.cwb.Customer.cid at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:71) at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:251) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:674) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605) at de.fzi.dbs.cwb.test.test.main(test.java:56) Caused by: 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:324) at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45) ... 4 more While debugging, I figured out, that the class' generator method returns "new Long(next++)" in any case - which causes the type-mismatch while trying to set the cid (customer id in my example). My solution to this is adding the following to generate-method in net.sf.hibernate.id.IncrementGenerator: public synchronized Serializable generate(SessionImplementor session, Object object) throws SQLException, HibernateException { if (sql!=null) { getNext( session.connection() ); } // added code: // determine the return type via SessionImplementor Type identifierType = session.getPersister(object).getIdentifierType(); if (identifierType instanceof net.sf.hibernate.type.IntegerType) { return new Integer((int)next++); } else if (identifierType instanceof net.sf.hibernate.type.ShortType) { return new Short((short)next++); } else { return new Long(next++); } }
    via by Florian Hübner,
  • As I use integer-type primary keys in the db I wanted to use the increment-generator to keep them unique. While trying to dump a test-object to the db, I got the following error: 15.08.2003 11:32:26 net.sf.hibernate.util.ReflectHelper$Setter set SCHWERWIEGEND: IllegalArgumentException in class: de.fzi.dbs.cwb.Customer, setter method of property: cid 15.08.2003 11:32:26 net.sf.hibernate.util.ReflectHelper$Setter set SCHWERWIEGEND: expected type: int, actual value: java.lang.Long net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of de.fzi.dbs.cwb.Customer.cid 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:324) at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45) at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:251) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:674) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605) (...) rethrown as net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of de.fzi.dbs.cwb.Customer.cid at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:71) at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:251) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:674) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605) at de.fzi.dbs.cwb.test.test.main(test.java:56) Caused by: 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:324) at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45) ... 4 more While debugging, I figured out, that the class' generator method returns "new Long(next++)" in any case - which causes the type-mismatch while trying to set the cid (customer id in my example). My solution to this is adding the following to generate-method in net.sf.hibernate.id.IncrementGenerator: public synchronized Serializable generate(SessionImplementor session, Object object) throws SQLException, HibernateException { if (sql!=null) { getNext( session.connection() ); } // added code: // determine the return type via SessionImplementor Type identifierType = session.getPersister(object).getIdentifierType(); if (identifierType instanceof net.sf.hibernate.type.IntegerType) { return new Integer((int)next++); } else if (identifierType instanceof net.sf.hibernate.type.ShortType) { return new Short((short)next++); } else { return new Long(next++); } }
    via by Florian Hübner,
  • org.springframework.beans.TypeMismatchExcepti
    via springframework by bitiboy
    ,
  • string to List mapping
    via dozer by pmdrafeeq
    ,
  • Re: IllegalAccess When Setting Field
    via by Chris Worley,
    • 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:324) at net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45) at net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:251) at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:674) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605)

    Users with the same issue

    tvrmsmithtvrmsmith
    2 times, last one,
    Unknown UserUnknown User
    2 times, last one,
    bernardpaulusbernardpaulus
    1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    johnxflyjohnxfly
    2 times, last one,
    94 more bugmates