org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of datos.Articulo.nroArticulo

Hibernate JIRA | IvanRF | 1 year ago
  1. 0

    After I do a simple {code:java} session.get(Class, Serializable) {code}, when I call {code:java} Transaction.commit() {code} I'm getting an error. * It's difficult to reproduce, it happens sometimes (not always, but it happens) * I debugged org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169) and after it reads correctly all the properties for my class (datos.Articulo), it tries to read the id again but target is a Boolean (false). So, the method object is {code:java} public java.lang.Integer datos.Articulo.getNroArticulo() {code} which expects an Integer as the ID. The target object is of class Boolean with value false, instead of being an Articulo class. I attached some images of the Thread stack and it seems it has something to do with ManyToOne. This is the definition of the column in the XML: {code:java} <id name="nroArticulo" type="int"> <column name="nro_articulo" /> <generator class="assigned" /> </id> {code} {panel:title=Debug error} 18:20:17,184 ERROR BasicPropertyAccessor:191 - HHH000122: IllegalArgumentException in class: datos.Articulo, getter method of property: nroArticulo org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of datos.Articulo.nroArticulo at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:192) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:346) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4746) at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4465) at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:243) at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:293) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:537) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:311) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:321) at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:310) at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:4243) at org.hibernate.event.internal.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:546) at org.hibernate.event.internal.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:232) at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:159) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:231) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:102) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177) .... Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169) ... 73 more {panel}

    Hibernate JIRA | 1 year ago | IvanRF
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of datos.Articulo.nroArticulo
  2. 0

    After I do a simple {code:java} session.get(Class, Serializable) {code}, when I call {code:java} Transaction.commit() {code} I'm getting an error. * It's difficult to reproduce, it happens sometimes (not always, but it happens) * I debugged org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169) and after it reads correctly all the properties for my class (datos.Articulo), it tries to read the id again but target is a Boolean (false). So, the method object is {code:java} public java.lang.Integer datos.Articulo.getNroArticulo() {code} which expects an Integer as the ID. The target object is of class Boolean with value false, instead of being an Articulo class. I attached some images of the Thread stack and it seems it has something to do with ManyToOne. This is the definition of the column in the XML: {code:java} <id name="nroArticulo" type="int"> <column name="nro_articulo" /> <generator class="assigned" /> </id> {code} {panel:title=Debug error} 18:20:17,184 ERROR BasicPropertyAccessor:191 - HHH000122: IllegalArgumentException in class: datos.Articulo, getter method of property: nroArticulo org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of datos.Articulo.nroArticulo at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:192) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:346) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4746) at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4465) at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:243) at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:293) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:537) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:311) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:321) at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:310) at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:4243) at org.hibernate.event.internal.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:546) at org.hibernate.event.internal.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:232) at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:159) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:231) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:102) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425) at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101) at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177) .... Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:169) ... 73 more {panel}

    Hibernate JIRA | 1 year ago | IvanRF
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of datos.Articulo.nroArticulo
  3. 0

    In mapping XML, at the time of resolving a property name to a field or getter/setter method Hibernate does not yet know the type. So if the class defines multiple potential matches based solely on name, Hibernate will not be able to adequately decide between them. At the moment it just picks the first one it sees. Unfortunately different JVMs (even different versions from the same VM vendor) returns the methods in different orders. So if we (for example) match a property named {{active}} to a getter method named {{isActive}}, check that there is also not a method named {{getActive}} of differing type. If we do find such a {{getActive}} method, throw the MappingException. ---- h4. Original Description It is the same bug as [HHH-10093|https://hibernate.atlassian.net/browse/HHH-10093], but for version 5.0.2. There you can find more information. Under Java 6 this does not happen, the exception is thrown when I use Java 8 (currently update 60). After I do a simple session.get(Class, Serializable) , when I call Transaction.commit(): It reads all the properties in the xml order without problems. After it reads the last property, the call with the issue is made. So, in DefaultFlushEntityEventListener line 135 {code:java} final Object[] values = getValues(...); {code} works fine. The issue appear on line 142 {code:java} if ( isUpdateNecessary( event, mightBeDirty ) ) { {code} *The owner object is of class Boolean with value false, instead of being an Articulo class.* {panel:title=Exception} {code:java} org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of datos.Articulo.nroArticulo at org.hibernate.property.access.spi.GetterMethodImpl.get(GetterMethodImpl.java:64) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:223) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4599) at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4311) at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:226) at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:276) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:455) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:281) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:291) at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:296) at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:4079) at org.hibernate.event.internal.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:532) at org.hibernate.event.internal.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:215) at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:142) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:216) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:85) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1224) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:464) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2894) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2270) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:485) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:230) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:65) {code} {panel}

    Hibernate JIRA | 1 year ago | IvanRF
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of datos.Articulo.nroArticulo
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    In mapping XML, at the time of resolving a property name to a field or getter/setter method Hibernate does not yet know the type. So if the class defines multiple potential matches based solely on name, Hibernate will not be able to adequately decide between them. At the moment it just picks the first one it sees. Unfortunately different JVMs (even different versions from the same VM vendor) returns the methods in different orders. So if we (for example) match a property named {{active}} to a getter method named {{isActive}}, check that there is also not a method named {{getActive}} of differing type. If we do find such a {{getActive}} method, throw the MappingException. ---- h4. Original Description It is the same bug as [HHH-10093|https://hibernate.atlassian.net/browse/HHH-10093], but for version 5.0.2. There you can find more information. Under Java 6 this does not happen, the exception is thrown when I use Java 8 (currently update 60). After I do a simple session.get(Class, Serializable) , when I call Transaction.commit(): It reads all the properties in the xml order without problems. After it reads the last property, the call with the issue is made. So, in DefaultFlushEntityEventListener line 135 {code:java} final Object[] values = getValues(...); {code} works fine. The issue appear on line 142 {code:java} if ( isUpdateNecessary( event, mightBeDirty ) ) { {code} *The owner object is of class Boolean with value false, instead of being an Articulo class.* {panel:title=Exception} {code:java} org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of datos.Articulo.nroArticulo at org.hibernate.property.access.spi.GetterMethodImpl.get(GetterMethodImpl.java:64) at org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:223) at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4599) at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4311) at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:226) at org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:276) at org.hibernate.type.EntityType.getIdentifier(EntityType.java:455) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:281) at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:291) at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:296) at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:4079) at org.hibernate.event.internal.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:532) at org.hibernate.event.internal.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:215) at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:142) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:216) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:85) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1224) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:464) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:2894) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2270) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:485) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:230) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:65) {code} {panel}

    Hibernate JIRA | 1 year ago | IvanRF
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of datos.Articulo.nroArticulo
  6. 0

    Getting hibernate error when using criteria

    Stack Overflow | 6 years ago | Noor
    org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.BiddingSystem.Models.Category.CategoryId

    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 calling getter of datos.Articulo.nroArticulo

      at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get()
    2. Hibernate
      AbstractTransactionImpl.commit
      1. org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:192)
      2. org.hibernate.tuple.entity.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:346)
      3. org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:4746)
      4. org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:4465)
      5. org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:243)
      6. org.hibernate.engine.internal.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:293)
      7. org.hibernate.type.EntityType.getIdentifier(EntityType.java:537)
      8. org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:311)
      9. org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:321)
      10. org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:310)
      11. org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:4243)
      12. org.hibernate.event.internal.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:546)
      13. org.hibernate.event.internal.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:232)
      14. org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:159)
      15. org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:231)
      16. org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:102)
      17. org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55)
      18. org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258)
      19. org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
      20. org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
      21. org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
      21 frames