net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of de.fzi.dbs.cwb.Customer.cid

Hibernate JIRA | Florian Hübner | 1 decade ago
  1. 0

    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++); } }

    Hibernate JIRA | 1 decade ago | Florian Hübner
    net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of de.fzi.dbs.cwb.Customer.cid
  2. 0

    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++); } }

    Hibernate JIRA | 1 decade ago | Florian Hübner
    net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling: argument type mismatch setter of de.fzi.dbs.cwb.Customer.cid
  3. 0

    strruts file upload problem(illegal argument exception)

    Google Groups | 1 decade ago | giggi
    java.lang.IllegalArgumentException: argument type mismatch
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    javax.servlet.ServletException: BeanUtils.populate

    com.br | 1 year ago
    java.lang.IllegalArgumentException: argument type mismatch
  6. 0

    org.springframework.beans.TypeMismatchExcepti

    springframework | 1 decade ago | bitiboy
    java.lang.IllegalArgumentException: argument type mismatch

  1. Aria Pahlavan 16 times, last 3 weeks ago
  2. kjhdofjosvs 2 times, last 1 month ago
  3. tyson925 2 times, last 1 month ago
  4. kuldeep 2 times, last 2 months ago
  5. aldrinleal 1 times, last 5 months ago
6 more registered users
72 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalArgumentException

    argument type mismatch

    at sun.reflect.NativeMethodAccessorImpl.invoke0()
  2. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    4. java.lang.reflect.Method.invoke(Method.java:324)
    4 frames
  3. net.sf.hibernate
    SessionImpl.save
    1. net.sf.hibernate.util.ReflectHelper$Setter.set(ReflectHelper.java:45)
    2. net.sf.hibernate.persister.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:251)
    3. net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:674)
    4. net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:605)
    4 frames
  4. de.fzi.dbs
    test.main
    1. de.fzi.dbs.cwb.test.test.main(test.java:56)
    1 frame