関連テーブルを使用して多対多の関係があります。
物体:
Foo
id;
name
Set<Foo> dependencies;
メインテーブル:
Foo
id
name
関連テーブル
foo_rel
parent_id <fk to Foo.id>
child_id <fk to Foo.id>
私の Foo.hbm.xml には、次のものがあります
<set name="dependencies" table="foo_rel" inverse="false" lazy="true" cascade="none" >
<key column="parent_id" />
<many-to-many column="child_id" class="Foo" />
</set>
問題は、同じ依存 Foo を持つ 2 つの新しい Foo オブジェクトを作成するたびに、foo_rel テーブルが更新されるため、最新の Foo オブジェクトの関連付けのみが保持されることです。
私が必要とするのは、関連付けテーブルに保持されている Foo とそれ自体の間の自己参照関係を持つことだけです。
ありがとう