I've been having some problems setting up a many-to-many association using 2 bags (I couldn't delete any elements form my association table without deleting a parent...)
So i wanted to give composite-elements a shot.
I've got a table Changes and another one Modules, linked in a third table ChangesModules.
In my the Module XML I've written:
Code:
<bag name="Changes" lazy="true" table="ChangesModules">
<key column="Module"/>
<composite-element class="Cevi.CeXLS.Hibernate.ChangesModules, Cevi.CeXLS.Hibernate">
<parent name="Module"/>
<many-to-one name="Changes" class="Cevi.CeXLS.Hibernate.Changes, Cevi.CeXLS.Hibernate" column="Changes" />
</composite-element>
</bag>
In the XML belonging to Changes:
Code:
<bag name="Modules" table="ChangesModules" lazy="true" inverse="true">
<key column="Changes"/>
<composite-element class="Cevi.CeXLS.Hibernate.ChangesModules, Cevi.CeXLS.Hibernate">
<parent name="Changes"/>
<many-to-one name="Module" class="Cevi.CeXLS.Hibernate.Module, Cevi.CeXLS.Hibernate" column="Module" />
</composite-element>
</bag>
I kept the properties I used during my frustrating exploration of many-to-many associations.
But now I get the following error when I try to fetch aChange.Modules or aModule.Changes:
Failed to lazily initialize a collection.
Changing both to lazy="false" results in the following error:
E = {"could not initialize a collection: [Cevi.CeXLS.Hibernate.Changes.Modules#190][SQL: SELECT modules0_.Changes as Changes__0_, modules0_.Module as Module0_ FROM CeXLS.dbo.ChangesModules modules0_ WHERE modules0_.Changes=?]"}
I hope someone can help me out here ...