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
|