Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hibernate WrongClassException ,table per class scheme

7 views
Skip to first unread message

Elhanan

unread,
Nov 15, 2006, 12:29:53 PM11/15/06
to
hi..
i have the following: (with hibernate 2.1.7c)

<class name="AbstractActivity" table="underwrite_activies">
<id column="ID" type="long" access="property" unsaved-value="-1">
<generator class="native"/>
</id>
<discriminator column="ActivtiyType"/>
<property name="code"/>
<subclass name="PursuitImpl" extends="AbstractActivity"
discriminator-value="P"/>
<subclass name="OccupationImpl" extends="AbstractActivity"
discriminator-value="O"/>

</class>

<class name="AssuredPersonImpl" table="underwrite_assuredpersons" >
<id column="ID" type="long" access="property" unsaved-value="-1">
<generator class="native"></generator>

</id>

<set name="pursuits" cascade="all-delete-orphan" access="field">
<key column="assuredPersonPrimayKey"/>
<one-to-many class="PursuitImpl"/>
</set>
<set name="occupations" cascade="all-delete-orphan"
access="field">
<key column="assuredPersonPrimayKey"/>
<one-to-many class="OccupationImpl"/>
</set>
</class>

saveing it is ok, however trying to access it i get (is this a bug?):
net.sf.hibernate.WrongClassException: Object with id: 37 was not of the
specified subclass: com.pnx.underwrite.bo.underwritemodel.PursuitImpl
(loaded object was of wrong class)
at
net.sf.hibernate.loader.Loader.instanceAlreadyLoaded(Loader.java:531)
at net.sf.hibernate.loader.Loader.getRow(Loader.java:498)
at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:213)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
at
net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:990)
at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:965)
at
net.sf.hibernate.loader.OneToManyLoader.initialize(OneToManyLoader.java:93)
at
net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:288)
at
net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3303)
at
net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:336)
at
net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3156)
at
net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1530)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1522)
at
com.pnx.underwrite.bo.underwritemodel.TestHibernate.testLoad(TestHibernate.java:111)
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:324)
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.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

0 new messages