Is it possible to make both end of a bidirectional many-to-many relation as a lazy collection. I marked both <set> with lazy="true" but only one end is lazy initialized.
Here is my mapping files.
Only Group.Users behaves as a lazy collection.
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="My.User, My" table="SecUser" dynamic-update="true" dynamic-insert="true" optimistic-lock="dirty">
<id name="KeyId" column="KeyId" type="Int32">
<generator class="assigned" />
</id>
<property name="UserName" type="String" length="50" />
<set name="Groups" access="NHibernate.Generics.GenericAccessor+CamelCase, NHibernate.Generics" table="SecMapUserGroup" inverse="false" lazy="true">
<key column="SecUserKeyId" />
<many-to-many class="My.Group, My" column="SecGroupKeyId"/>
</set>
</class>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="My.Group, My" table="SecGroup" dynamic-update="true" dynamic-insert="true" optimistic-lock="dirty">
<id name="KeyId" column="KeyId" type="Int32">
<generator class="assigned" />
</id>
<property name="GroupName" type="String" length="50" />
<set name="Users" access="NHibernate.Generics.GenericAccessor+CamelCase, NHibernate.Generics" table="SecMapUserGroup" inverse="true" lazy="true">
<key column="SecGroupKeyId" />
<many-to-many class="My.User, My" column="SecUserKeyId"/>
</set>
</class>
</hibernate-mapping>