org.hibernate.PropertyAccessException

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.

  • Campo Autoincremental - Components
    via openxava by saamondino
    ,
  • 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
    via by Luca Dall'Olio,
  • 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
    via by Luca Dall'Olio,
  • DB migration error
    via GitHub by Abyss777
    ,
    • org.hibernate.PropertyAccessException: could not set a field value by reflection setter of org.openxava.sinseq.modelo.Almacen.idkk at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:82) at org.hibernate.tuple.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:204) at org.hibernate.tuple.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:346) at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:3272) at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1260) at org.hibernate.impl.SessionImpl.instantiate(SessionImpl.java:1249) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1291) at org.hibernate.loader.Loader.getRow(Loader.java:1197) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:569) at org.hibernate.loader.Loader.doQuery(Loader.java:689)

    Users with the same issue

    nasimknasimk
    3 times, last one,