Hi all,
I tried posting this in another thread but I fear I've mis-named it as I'm not really getting any responses to this particular issue.
I'm getting an exception thrown from my CGLIB-generated class - here's the stack trace from Ant -
Code:
[junit] org.hibernate.PropertyAccessException: exception setting property value with CGLIB (set hibernate.cglib.use_reflection_optimizer=false for more info) setter of net.hatfieldgroup.rampv2.biz.wq.WQSample.setAnalyteID
[junit] at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:203)
[junit] at org.hibernate.tuple.PojoTuplizer.setPropertyValues(PojoTuplizer.java:173)
[junit] at org.hibernate.persister.entity.BasicEntityPersister.setPropertyValues(BasicEntityPersister.java:2919)
[junit] at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:113)
[junit] at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
[junit] at org.hibernate.loader.Loader.doQuery(Loader.java:436)
[junit] at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
[junit] at org.hibernate.loader.Loader.doList(Loader.java:1593)
[junit] at org.hibernate.loader.Loader.list(Loader.java:1577)
[junit] at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
[junit] at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
[junit] at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
[junit] at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
[junit] at net.hatfieldgroup.rampv2.test.TestWQAnalyte.testGetFullList(TestWQAnalyte.java:37)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[junit] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[junit] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[junit] at java.lang.reflect.Method.invoke(Unknown Source)
[junit] at junit.framework.TestCase.runTest(TestCase.java:154)
[junit] at junit.framework.TestCase.runBare(TestCase.java:127)
[junit] at junit.framework.TestResult$1.protect(TestResult.java:106)
[junit] at junit.framework.TestResult.runProtected(TestResult.java:124)
[junit] at junit.framework.TestResult.run(TestResult.java:109)
[junit] at junit.framework.TestCase.run(TestCase.java:118)
[junit] at junit.framework.TestSuite.runTest(TestSuite.java:208)
[junit] at junit.framework.TestSuite.run(TestSuite.java:203)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:297)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeInVM(JUnitTask.java:1072)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:682)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeOrQueue(JUnitTask.java:1434)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute(JUnitTask.java:632)
[junit] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
[junit] at org.apache.tools.ant.Task.perform(Task.java:364)
[junit] at org.apache.tools.ant.Target.execute(Target.java:341)
[junit] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[junit] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)
[junit] at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
[junit] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40)
[junit] at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
[junit] at org.apache.tools.ant.Main.runBuild(Main.java:668)
[junit] at org.apache.tools.ant.Main.startAnt(Main.java:187)
[junit] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
[junit] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
[junit] Caused by: net.sf.cglib.beans.BulkBeanException: net.hatfieldgroup.rampv2.biz.wq.WQAnalyte$$EnhancerByCGLIB$$b20220ef
[junit] at net.hatfieldgroup.rampv2.biz.wq.WQSample$$BulkBeanByCGLIB$$1ec8c312.setPropertyValues(<generated>)
[junit] at org.hibernate.tuple.PojoTuplizer.setPropertyValuesWithOptimizer(PojoTuplizer.java:200)
[junit] ... 42 more
[junit] Caused by: java.lang.ClassCastException: net.hatfieldgroup.rampv2.biz.wq.WQAnalyte$$EnhancerByCGLIB$$b20220ef
[junit] ... 44 more
The code for my WQSample class:
Code:
package net.hatfieldgroup.rampv2.biz.wq;
import net.hatfieldgroup.rampv2.db.*;
import java.sql.Timestamp;
public class WQSample
{
private Long sampleID;
private Timestamp samplingDate;
private String siteID;
private Long analyteID;
private double detectionLimit;
private String resultQualifier;
private double result;
private String lab;
private String analyticalMethod;
public Long getSampleID(){
return sampleID;
}
public Timestamp getSamplingDate(){
return samplingDate;
}
public String getSiteID(){
return siteID;
}
public Long getAnalyteID(){
return analyteID;
}
public double getDetectionLimit(){
return detectionLimit;
}
public String getResultQualifier(){
return resultQualifier;
}
public double getResult(){
return result;
}
public String getLab(){
return lab;
}
public String getAnalyticalMethod(){
return analyticalMethod;
}
public void setSampleID(Long sampleID){
this.sampleID = sampleID;
}
public void setSamplingDate(Timestamp samplingDate){
this.samplingDate = samplingDate;
}
public void setSiteID(String siteID){
this.siteID = siteID;
}
public void setAnalyteID(Long analyteID){
this.analyteID = analyteID;
}
public void setDetectionLimit(double detectionLimit){
this.detectionLimit = detectionLimit;
}
public void setResultQualifier(String resultQualifier){
this.resultQualifier = resultQualifier;
}
public void setResult(double result){
this.result = result;
}
public void setLab(String lab){
this.lab = lab;
}
public void setAnalyticalMethod(String analyticalMethod){
this.analyticalMethod = analyticalMethod;
}
};
The mapping for WQSample:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="net.hatfieldgroup.rampv2.biz.wq.WQSample" table="WQSAMPLE">
<id name="sampleID" column="sampleID" type="java.lang.Long">
<generator class="native" />
</id>
<property name="samplingDate" type="java.sql.Timestamp" />
<property name="detectionLimit" type="double" />
<property name="resultQualifier" type="java.lang.String" />
<property name="result" type="double" />
<property name="lab" type="java.lang.String" />
<property name="analyticalMethod" type="java.lang.String" />
<many-to-one name="analyteID" class="net.hatfieldgroup.rampv2.biz.wq.WQAnalyte" column="analyteID"/>
<!-- <many-to-one name="siteID" class="net.hatfieldgroup.rampv2.biz.wq.WQSite" column="siteID"/> -->
</class>
</hibernate-mapping>
And the mapping for WQAnalyte:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="net.hatfieldgroup.rampv2.biz.wq.WQAnalyte" table="WQANALYTE">
<id name="analyteID" column="analyteID" type="java.lang.Long">
<generator class="native" />
</id>
<property name="analyteName" type="java.lang.String" />
<property name="analyteCategory" type="java.lang.String" />
<property name="units" type="java.lang.String" />
<property name="abbreviation" type="java.lang.String" />
<set name="samples" cascade="all" inverse="false" lazy="true">
<key column="sampleID" />
<one-to-many class="net.hatfieldgroup.rampv2.biz.wq.WQSample" />
</set>
</class>
</hibernate-mapping>
I've tried changing all the java.lang.Long values to primitive longs, then to primitive ints, and neither change makes any difference.
I've also checked the DB to make sure there are no null values in any of the referenced columns, and there aren't.
Not sure what else to do here, this is proving very hard to debug because I can't find any references to this problem actually being resolved on this site or on google, although it looks like it IS a common problem.
If anyone has any ideas they'd be much appreciated, my app is basically stuck broken at this point.