I believe I have found a Hibernate bug. I know that 99% of "bugs" are actually user errors. However...
I get the following exception. Note that the relevant column is set to "NOT NULL"; there are absolutely no NULL values in the database. I get this error both when doing a query and with a record create.
Hibernate: 3.0.5
MySQL: 4.1.13
If anyone could help resolve, I would greatly appreciate it.
Code:
Caused by: org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.auenrec.data.Rating.enabled
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:59)
at org.hibernate.tuple.AbstractTuplizer.setPropertyValues(AbstractTuplizer.java:207)
at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:176)
at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
at org.hibernate.loader.Loader.doQuery(Loader.java:436)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:75)
at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:643)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at com.auenrec.data.Rating$$EnhancerByCGLIB$$ade24074.setRatingDate(<generated>)
at com.auenrec.webbean.ItemRater.doRateItem(Unknown Source)
at com.auenrec.webbean.ItemRater.getArtificalLoadTrigger(Unknown Source)
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 com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:79)
... 54 more
Caused by: java.lang.IllegalArgumentException
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 org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:40)
... 81 more
Relevant code from Rating.java:
Code:
// Internal instance variable declaration
private boolean enabled = true;
// Accessors
public boolean getEnabled() { return enabled; }
public void setEnabled(boolean enabled) { this.enabled = enabled; }
Relevant code from mapping file:
Code:
<class name="com.auenrec.data.Rating" table="Ratings">
<composite-id>
<key-many-to-one name="user" column="UserID"
class="com.auenrec.data.GenericUser"/>
<key-many-to-one name="item" column="RatableItemID"
class="com.auenrec.data.RatableItem"/>
</composite-id>
<property name="originalRating" column="OriginalRating" type="float"/>
<property name="normalizedRating" column="NormalizedRating" type="float"/>
<property name="ratingDate" column="RatingDate" type="timestamp"/>
<property name="enabled" column="Enabled" type="boolean"/>
</class>
MySQL table description:
Code:
+------------------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------------+------------+------+-----+---------+-------+
| UserID | int(11) | | PRI | 0 | |
| RatableItemID | int(11) | | PRI | 0 | |
| OriginalRating | float | YES | | NULL | |
| NormalizedRating | float | YES | | NULL | |
| RatingDate | datetime | YES | | NULL | |
| Enabled | tinyint(1) | | | 1 | |
+------------------+------------+------+-----+---------+-------+