net.sf.hibernate.PropertyAccessException: could not get a field value by reflection getter of com.companio.f5.app.example.persistence.db1.EntityProject.id

Hibernate JIRA | Stefan Wachter | 1 decade ago
  1. 0

    ...unless log level set to DEBUG. Assume we have 3 entities known by Hibernate: customer, product, address Customer has n products, if I say customer.getProducts().add( address ); // wrong type session.save(customer); Hibernate does not complain but simply does NOT SAVE the entities! Note: for customer.getAccounts().add("wrong account type"); // wrong type session.save(customer); Hibernate says: "No persister for..." - that's why I used the address instance which is known by Hibernate. Now what's really interesting: Hibernate behaves correctly when loglevel for net.sf.hibernate is set to DEBUG, in this case it gives the following exception: net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of mypackage.Product.id at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:114) at net.sf.hibernate.persister.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:306) at net.sf.hibernate.proxy.HibernateProxyHelper.getIdentifier(HibernateProxyHelper.java:48) at net.sf.hibernate.type.EntityType.toString(EntityType.java:84) at net.sf.hibernate.type.PersistentCollectionType.toString(PersistentCollectionType.java:82) at net.sf.hibernate.impl.Printer.toString(Printer.java:49) at net.sf.hibernate.impl.Printer.toString(Printer.java:82) at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2270) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2228) at org.springframework.orm.hibernate.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:214) at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:313) at org.springframework.orm.hibernate.HibernateTemplate.save(HibernateTemplate.java:491) at ... 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:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:100) ... 28 more If you go down the trace, you'll see that Printer.toString(Iterator iter) triggers the querying of the ID, this method in turn starts with if ( !log.isDebugEnabled() || !iter.hasNext() ) return; No matter what you do about the typesafety issue, which is probably gone with Generics, Hibernate should behave the same independently from the log level.

    Hibernate JIRA | 1 decade ago | Jonas Kilian
    net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of mypackage.Product.id
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    Hibernate Community • View topic - junit fails with mysql

    hibernate.org | 8 months ago
    net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of org.hibernate.test.Jay.id
  4. 0

    ...unless log level set to DEBUG. Assume we have 3 entities known by Hibernate: customer, product, address Customer has n products, if I say customer.getProducts().add( address ); // wrong type session.save(customer); Hibernate does not complain but simply does NOT SAVE the entities! Note: for customer.getAccounts().add("wrong account type"); // wrong type session.save(customer); Hibernate says: "No persister for..." - that's why I used the address instance which is known by Hibernate. Now what's really interesting: Hibernate behaves correctly when loglevel for net.sf.hibernate is set to DEBUG, in this case it gives the following exception: net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of mypackage.Product.id at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:114) at net.sf.hibernate.persister.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:306) at net.sf.hibernate.proxy.HibernateProxyHelper.getIdentifier(HibernateProxyHelper.java:48) at net.sf.hibernate.type.EntityType.toString(EntityType.java:84) at net.sf.hibernate.type.PersistentCollectionType.toString(PersistentCollectionType.java:82) at net.sf.hibernate.impl.Printer.toString(Printer.java:49) at net.sf.hibernate.impl.Printer.toString(Printer.java:82) at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2270) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2228) at org.springframework.orm.hibernate.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:214) at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:313) at org.springframework.orm.hibernate.HibernateTemplate.save(HibernateTemplate.java:491) at ... 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:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at net.sf.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:100) ... 28 more If you go down the trace, you'll see that Printer.toString(Iterator iter) triggers the querying of the ID, this method in turn starts with if ( !log.isDebugEnabled() || !iter.hasNext() ) return; No matter what you do about the typesafety issue, which is probably gone with Generics, Hibernate should behave the same independently from the log level.

    Hibernate JIRA | 1 decade ago | Jonas Kilian
    net.sf.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of mypackage.Product.id

    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. net.sf.hibernate.PropertyAccessException

      could not get a field value by reflection getter of com.companio.f5.app.example.persistence.db1.EntityProject.id

      at net.sf.hibernate.property.DirectPropertyAccessor$DirectGetter.get()
    2. net.sf.hibernate
      SessionImpl.flush
      1. net.sf.hibernate.property.DirectPropertyAccessor$DirectGetter.get(DirectPropertyAccessor.java:32)
      2. net.sf.hibernate.persister.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:306)
      3. net.sf.hibernate.proxy.HibernateProxyHelper.getIdentifier(HibernateProxyHelper.java:48)
      4. net.sf.hibernate.type.EntityType.toString(EntityType.java:84)
      5. net.sf.hibernate.type.PersistentCollectionType.toString(PersistentCollectionType.java:82)
      6. net.sf.hibernate.impl.Printer.toString(Printer.java:49)
      7. net.sf.hibernate.impl.Printer.toString(Printer.java:82)
      8. net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2277)
      9. net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2235)
      9 frames
    3. de.companio.c5
      HibernateAccessorDesc.flushPhase2
      1. de.companio.c5.schema.persistence.HibernateAccessorDesc.flushPhase2(HibernateAccessorDesc.java:148)
      1 frame