Problem:
Can't set a property on a static inner class.
If I add a getter/setter pair, and set access=property, then the setter is not found
Hibernate version:
3.1.1
Mapping documents:
Code:
<!-- using an existing domain model where many classes are marked
as final, and setters do not exist always -->
hibernate.cglib.use_reflection_optimizer=false
hibernate.max_fetch_depth=1
<hibernate-mapping default-access="field" default-lazy="false">
<class name="de.acme.Outer" table="outerTable">
<id name="id" column="id">
<generator class="sequence">
<param name="sequence">SEQ_acme</param>
</generator>
</id>
<many-to-one name="nested" class="de.acme.Outer$Inner" column="innerTable" fetch="join"/>
</class>
<class name="de.acme.Outer$Inner" table="innerTable">
<id name="id" column="id"/>
<property name="customerScore" column="score"/>
</class>
</hibernate>
java classesCode:
public final class Outer extends Base
{
private int id;
private Outer outer;
public static class Outer extends Base
{
private int id;
// DB column is NUMBER
private int customerScore;
}
}
Full stack trace of any exception that occurs:Code:
13:15:28.519 INFO [DefaultLoadEventListener]- <Error performing load command>
org.hibernate.PropertyAccessException: could not set a field value by reflection setter of de.acme.OuterClass$InnerClass.customerScore at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:81)
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.proxyOrLoad(DefaultLoadEventListener.java:151)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
at
Caused by: java.lang.IllegalArgumentException
at sun.reflect.UnsafeIntegerFieldAccessorImpl.set(Unknown Source)
at java.lang.reflect.Field.set(Unknown Source)
at org.hibernate.property.DirectPropertyAccessor$DirectSetter.set(DirectPropertyAccessor.java:78)
... 36 more
Name and version of the database you are using:
Oracel9i
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: