org.hibernate.PropertyAccessException: could not set a field value by reflection setter of peralex.grj8000.datastore.SweepJamBand.selected

Hibernate JIRA | Noel Grandin | 10 years ago
  1. 0

    I have hibernate.hbm2ddl.auto=update and I have an existing database with existing tables. I updated one of the domain objects to have a new boolean field. When I started my app, it failed when it tried to load the domain object, with the following stacktrace: [0@15:39:41.551] !SE>: org.hibernate.PropertyAccessException: could not set a field value by reflection setter of peralex.grj8000.datastore.SweepJamBand.selected at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:82) at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337) at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200) at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3514) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842) at org.hibernate.loader.Loader.doQuery(Loader.java:717) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadCollection(Loader.java:1985) at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163) at peralex.client.control.Control.loadSelectedLibrary(Control.java:334) Caused by: java.lang.IllegalArgumentException at sun.reflect.UnsafeBooleanFieldAccessorImpl.set(UnsafeBooleanFieldAccessorImpl.java:62) at java.lang.reflect.Field.set(Field.java:656) at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:79) ... 36 more When I looked in the database, I noted that the table had been incorrectly updated with a nullable column for the new field. Using my debugger I confirmed that Hibernate was attempting to load a "null" value into a primitive boolean field. I worked around this by specifying @Column(columnDefinition="smallint not null default 0" ) private boolean selected; on my new field.

    Hibernate JIRA | 10 years ago | Noel Grandin
    org.hibernate.PropertyAccessException: could not set a field value by reflection setter of peralex.grj8000.datastore.SweepJamBand.selected
  2. 0

    I have hibernate.hbm2ddl.auto=update and I have an existing database with existing tables. I updated one of the domain objects to have a new boolean field. When I started my app, it failed when it tried to load the domain object, with the following stacktrace: [0@15:39:41.551] !SE>: org.hibernate.PropertyAccessException: could not set a field value by reflection setter of peralex.grj8000.datastore.SweepJamBand.selected at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:82) at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337) at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200) at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3514) at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129) at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842) at org.hibernate.loader.Loader.doQuery(Loader.java:717) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadCollection(Loader.java:1985) at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) at org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163) at peralex.client.control.Control.loadSelectedLibrary(Control.java:334) Caused by: java.lang.IllegalArgumentException at sun.reflect.UnsafeBooleanFieldAccessorImpl.set(UnsafeBooleanFieldAccessorImpl.java:62) at java.lang.reflect.Field.set(Field.java:656) at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:79) ... 36 more When I looked in the database, I noted that the table had been incorrectly updated with a nullable column for the new field. Using my debugger I confirmed that Hibernate was attempting to load a "null" value into a primitive boolean field. I worked around this by specifying @Column(columnDefinition="smallint not null default 0" ) private boolean selected; on my new field.

    Hibernate JIRA | 10 years ago | Noel Grandin
    org.hibernate.PropertyAccessException: could not set a field value by reflection setter of peralex.grj8000.datastore.SweepJamBand.selected
  3. 0

    IllegalArgumentException when setting public member

    Stack Overflow | 8 years ago | colinjwebb
    java.lang.IllegalArgumentException
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  1. Indri Yunita 183 times, last 2 days ago
  2. Alexandru Popa 1 times, last 3 weeks ago
  3. filpgame 5 times, last 6 days ago
  4. eti22 4 times, last 3 months ago
  5. smyrgeorge 1 times, last 4 months ago
2 more registered users
27 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

    No message provided

    at sun.reflect.UnsafeBooleanFieldAccessorImpl.set()
  2. Java RT
    Field.set
    1. sun.reflect.UnsafeBooleanFieldAccessorImpl.set(UnsafeBooleanFieldAccessorImpl.java:62)
    2. java.lang.reflect.Field.set(Field.java:656)
    2 frames
  3. Hibernate
    AbstractCollectionPersister.initialize
    1. org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:79)
    2. org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:82)
    3. org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
    4. org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
    5. org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3514)
    6. org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
    7. org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
    8. org.hibernate.loader.Loader.doQuery(Loader.java:717)
    9. org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
    10. org.hibernate.loader.Loader.loadCollection(Loader.java:1985)
    11. org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
    12. org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
    12 frames
  4. Hibernate
    PersistentSet.iterator
    1. org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
    2. org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
    3. org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
    4. org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
    5. org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:163)
    5 frames
  5. peralex.client.control
    Control.loadSelectedLibrary
    1. peralex.client.control.Control.loadSelectedLibrary(Control.java:334)
    1 frame