[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2644) hbm2ddl.auto creates nullable column for primitive boolean on Derby database

Noel Grandin (JIRA) noreply at atlassian.com
Wed May 30 09:42:04 EDT 2007


hbm2ddl.auto creates nullable column for primitive boolean on Derby database
----------------------------------------------------------------------------

                 Key: HHH-2644
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2644
             Project: Hibernate3
          Issue Type: Bug
          Components: core
    Affects Versions: 3.2.0.ga
         Environment: Hibernate 3.2,
Derby 10.2.20
            Reporter: Noel Grandin
            Priority: Minor


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 at 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.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list