3.0.5:
Mapping Classes:
Film:
<joined-subclass extends="IP" name="Film" table="film">
<key column="id"/>
<set name="rightsMatrix"
cascade="save-update" inverse="true" lazy="true">
<key column="film_id"/>
<one-to-many class="FilmRight"/>
</set>
<set name="filmMedia"
cascade="all-delete-orphan" inverse="true" lazy="true">
<key column="film_id"/>
<one-to-many class="FilmMedia"/>
</set>
</joined-subclass>
Film Media:
<class name="FilmMedia" table="film_media">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="hilo"/>
</id>
<many-to-one name="film" class="Film" column="film_id"/>
</class>
Film Rights Matrix:
<class name="FilmRight" table="film_rights_matrix">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="hilo"/>
</id>
<many-to-one name="film" class="Film" column="film_id"/>
</class>
Code:
Film f = Session.load(...);
As expected, loading film does not load rights Matrix nor film media
since lazy="true"
Problem:
f.getFilmMedia(); loads rights matrix, I am puzzled that rights are getting loaded when lazy is set to true.
How to force lazy for many-to-one associations?
|