Hey,
again a flush-cascade problem!
I have a complex construct of relations and
any type mappings!
Class A(JasBeanImpl) stands in a bidirectional one-to-many relationship
with class B(KeyValueTuple)!
Code:
<set name="KeyValueTuples"
lazy="true"
inverse="true"
cascade="all-delete-orphan">
<key column="fkJasBean"/>
<one-to-many class="org.weta.jas.hibernate.KeyValueTuple"/>
</set>
Class B(KeyValueTuple) uses
any type mapping :
Code:
<any name="value"
id-type="long"
cascade="all" >
<column name="class_name" />
<column name="class_id" />
</any>
The
any type mapping of class B should f.e reference a collection of objects, so i wrote a class C (HValueCollection), which stands in a one-to-many relation with class D (HValue)!
Code:
<set name="HValues"
lazy="true"
inverse="true"
cascade="all-delete-orphan">
<key column="fkCollection"/>
<one-to-many class="org.weta.jas.hibernate.HValue"/>
</set>
Class D itself has a
any type mapping too!
Code:
<any name="value"
id-type="long"
cascade="all">
<column name="class_name" />
<column name="class_id" />
</any>
Thats the basic structure!
(A----
rel----B----
any----C----
rel----D----
any----..)
Now saving works fine!
Quote:
(1)
If i remove an object of class A (
remove(a);) it still works, everything which stands in relation or is referenced from a is deleted!
Quote:
(2)
If i remove an object of class B(b child of A), which
any type mapping points to a standalone hibernate class Z, it works too!
Quote:
(3)
But if i remove an object of class B which
any type mapping points to an object of class C, following error occured:
[STDERR] net.sf.hibernate.HibernateException: Flush during cascad
en re-saved by cascade (remove deleted object from associations)
ibernate.impl.SessionImpl.flush(SessionImpl.java:2176)
...I remove it just by removing the element from the Set of class A, and update class A. (update()+flush())
I tried to use proxys and override equals() for all classes.
I tried to set all cascades to none, saving and deleting all manually, but in case
Quote:
(3)
still the same error!
Quote:
(4)
If i create an object of class C with some mappings to D, deleting works,
Just all in all the error appears!
I have no more ideas...