org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of it.unimaticaspa.unique.pe.spec.entity.EntityBase.entityPK

Hibernate JIRA | Luca Dall'Olio | 10 years ago
  1. 0

    When executing a criteria query with a custom <id> type, hibernate ignores the custom type trying to set a primitive type instead; whereas load() works succesfully : Below is some code that helps reproducing this problem : Example of a custom Identifier Generator : package sample; ... public class CustomIdentifierGenerator implements IdentifierGenerator, PostInsertIdentifierGenerator, Configurable { private static IdentityGenerator hibernateGeneratorDelegate = null; public void configure(Type type, Properties props, Dialect dialect) throws MappingException { hibernateGeneratorDelegate = IdentifierGeneratorFactory.create( "sequence", new LongType(), props, dialect); if (hibernateGeneratorDelegate instanceof Configurable) { ((Configurable) hibernateGeneratorDelegate).configure( new LongType(), props, dialect); } } public Serializable generate(SessionImplementor session, Object object) throws HibernateException { return hibernateGeneratorDelegate.generate(session, object); } public InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate( PostInsertIdentityPersister persister, Dialect dialect, boolean isUseGet) throws HibernateException { return hibernateGeneratorDelegate.getInsertGeneratedIdentifierDelegate(persister, dialect, isUseGet); } } Mapping snippet : <class name="sample.SimpleEntity" table="TB_SMP_SIMPLE"> <id name="entityPK" type="sample.LongEntityPK" column="SMP_ID"> <generator class="sample.CustomIdentifierGenerator" /> </id> </class> Entity class : package sample; .... public class SimpleEntity { Query code : SimpleEntity de = new SimpleEntity(); s.save(de); // Read SimpleEntity de2 = (SimpleEntity) s.load(SimpleEntity.class, de .getEntityPK()); assertNotNull(de2); assertEquals(de, de2); // Query Criteria crit = s.createCriteria(SimpleEntity.class); List results = crit.list(); // FAILING!!! IllegalArgumentException in class: it.unimaticaspa.unique.pe.spec.entity.EntityBase, setter method of property: entityPK // expected type: it.unimaticaspa.unique.pe.spec.entity.IEntityPK, actual value: java.lang.Long Logs : IllegalArgumentException in class: it.unimaticaspa.unique.pe.spec.entity.EntityBase, setter method of property: entityPK expected type: it.unimaticaspa.unique.pe.spec.entity.IEntityPK, actual value: java.lang.Long Error StackTrace: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of it.unimaticaspa.unique.pe.spec.entity.EntityBase.entityPK at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104) at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:211) at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:353) at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3600) at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1275) ... at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42) ... 35 more

    Hibernate JIRA | 10 years ago | Luca Dall'Olio
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of it.unimaticaspa.unique.pe.spec.entity.EntityBase.entityPK
  2. 0

    When executing a criteria query with a custom <id> type, hibernate ignores the custom type trying to set a primitive type instead; whereas load() works succesfully : Below is some code that helps reproducing this problem : Example of a custom Identifier Generator : package sample; ... public class CustomIdentifierGenerator implements IdentifierGenerator, PostInsertIdentifierGenerator, Configurable { private static IdentityGenerator hibernateGeneratorDelegate = null; public void configure(Type type, Properties props, Dialect dialect) throws MappingException { hibernateGeneratorDelegate = IdentifierGeneratorFactory.create( "sequence", new LongType(), props, dialect); if (hibernateGeneratorDelegate instanceof Configurable) { ((Configurable) hibernateGeneratorDelegate).configure( new LongType(), props, dialect); } } public Serializable generate(SessionImplementor session, Object object) throws HibernateException { return hibernateGeneratorDelegate.generate(session, object); } public InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate( PostInsertIdentityPersister persister, Dialect dialect, boolean isUseGet) throws HibernateException { return hibernateGeneratorDelegate.getInsertGeneratedIdentifierDelegate(persister, dialect, isUseGet); } } Mapping snippet : <class name="sample.SimpleEntity" table="TB_SMP_SIMPLE"> <id name="entityPK" type="sample.LongEntityPK" column="SMP_ID"> <generator class="sample.CustomIdentifierGenerator" /> </id> </class> Entity class : package sample; .... public class SimpleEntity { Query code : SimpleEntity de = new SimpleEntity(); s.save(de); // Read SimpleEntity de2 = (SimpleEntity) s.load(SimpleEntity.class, de .getEntityPK()); assertNotNull(de2); assertEquals(de, de2); // Query Criteria crit = s.createCriteria(SimpleEntity.class); List results = crit.list(); // FAILING!!! IllegalArgumentException in class: it.unimaticaspa.unique.pe.spec.entity.EntityBase, setter method of property: entityPK // expected type: it.unimaticaspa.unique.pe.spec.entity.IEntityPK, actual value: java.lang.Long Logs : IllegalArgumentException in class: it.unimaticaspa.unique.pe.spec.entity.EntityBase, setter method of property: entityPK expected type: it.unimaticaspa.unique.pe.spec.entity.IEntityPK, actual value: java.lang.Long Error StackTrace: org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of it.unimaticaspa.unique.pe.spec.entity.EntityBase.entityPK at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104) at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:211) at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:353) at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3600) at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1275) ... at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42) ... 35 more

    Hibernate JIRA | 10 years ago | Luca Dall'Olio
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of it.unimaticaspa.unique.pe.spec.entity.EntityBase.entityPK
  3. 0

    OpenXava / Discussion / Ayuda (Español):Campo Autoincremental - Components

    sourceforge.net | 1 year ago
    org.hibernate.PropertyAccessException: could not set a field value by reflection setter of org.openxava.sinseq.modelo.Almacen.idkk
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Campo Autoincremental - Components

    openxava | 1 decade ago | saamondino
    org.hibernate.PropertyAccessException: could not set a field value by reflection setter of org.openxava.sinseq.modelo.Almacen.idkk
  6. 0

    Hibernate Community • View topic - Embedded IllegalArgumentException: argument type mismatch

    hibernate.org | 5 months ago
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.amazon.otb.model.PlanningLevelData.category

    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. org.hibernate.PropertyAccessException

      IllegalArgumentException occurred while calling setter of it.unimaticaspa.unique.pe.spec.entity.EntityBase.entityPK

      at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set()
    2. Hibernate
      AbstractEntityPersister.instantiate
      1. org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104)
      2. org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:211)
      3. org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:353)
      4. org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3600)
      4 frames
    3. Hibernate
      SessionImpl.instantiate
      1. org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1275)
      1 frame