I have a class that is generating this Hibernate exception. If anyone could spot my error, I would greatly appreciate it. This is with Hibernate 3.0.5
Exception trace:
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)
(snip)
... 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) | YES | | NULL | |
+------------------+------------+------+-----+---------+-------+