JDK 1.5.0_04
Hibernate version: 3.0.5
Mapping documents:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="au.gov.vic.ngv.shop.admin.model.Person">
<id name="ID">
<generator class="increment"/>
</id>
<property name="name"/>
<joined-subclass name="au.gov.vic.ngv.shop.admin.model.Manager" lazy="false">
<key column="ID"/>
<property name="bonus"/>
</joined-subclass>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
Manager manager = (Manager) sess.load(Person.class,new Long(1));
Full stack trace of any exception that occurs:java.lang.ClassCastException: au.gov.vic.ngv.shop.admin.model.Person$$EnhancerByCGLIB$$36a08cbc
at au.gov.vic.ngv.shop.admin.dao.TestProductDAO.testLoadPerson(TestProductDAO.java:29)
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 junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Name and version of the database you are using: SQL Server 2000
I can't understand why this is not working and I've searched everywhere. Can anyone see if I may have missed anything?
If I use Manager.class in the load() method instead of the superclass:
Code:
Manager manager = (Manager) sess.load(Manager.class,new Long(1));
it works fine, but this means I can't load objects polymorphically.