-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ClassCastException on cascade delete
PostPosted: Fri Apr 06, 2007 9:32 am 
Newbie

Joined: Wed May 10, 2006 6:04 am
Posts: 4
Hello,

I've a class named Extensible that has a one-to-may association with a class named AdditionalField. AdditionalField is not abstract and has sublcasses: BooleanField, NumericField etc..
For the inheritance I use a strategy "one table per hierachy".
Is use the "delete-orphan" tag on the association.

But When I try to delete the Extensible, I get the following exception:

org.hibernate.HibernateException: instance not of expected entity type: com.alca
tel.matisse.datamodel.extensions.AdditionalField
at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEnt
ityPersister(AbstractEntityPersister.java:3301)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:12
81)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180)
at org.hibernate.engine.ForeignKeys.isNotTransient(ForeignKeys.java:157)

at org.hibernate.engine.CascadingAction$2.cascade(CascadingAction.java:4
6)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:2
90)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:185)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:160)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.engine.Cascade.cascade(Cascade.java:223)
at org.hibernate.event.def.DefaultDeleteEventListener.cascadeBeforeDelet
e(DefaultDeleteEventListener.java:220)
at org.hibernate.event.def.DefaultDeleteEventListener.deleteEntity(Defau
ltDeleteEventListener.java:169)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDe
leteEventListener.java:110)
at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:764)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:743)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtection
Wrapper.invoke(ThreadLocalSessionContext.java:292)
at $Proxy1.delete(Unknown Source)
at com.alcatel.matisse.datamodel.DatamodelTest.testDeleteAgent(Datamodel
Test.java:769)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.jav
a:210)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTes
tSet(AbstractDirectoryTestSuite.java:135)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(Ab
stractDirectoryTestSuite.java:122)
at org.apache.maven.surefire.Surefire.run(Surefire.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(Su
refireBooter.java:225)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.j
ava:747)

I had the same kind of problem when setting "all-dlepete-orphan" and trying to add different kinds of AdditionalField to the Extensible.

When I remove the "delete-orphan", all is OK except that the children fields are not deleted.

So, Am I missing something


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.