We have the problem, that when we restrict the one side of a
many-to-one association with a 'where' attribute, lazy loading is
switched off always.
The mapping we are using looks like
Code:
<class
name="Board"
table="t_board"
dynamic-update="true"
dynamic-insert="true"
>
<!-- ...... -->
<list
name="standardTopics"
lazy="true"
inverse="false"
where="category = 'S'"
>
<key column="board_id"/>
<list-index column="board_index"/>
<one-to-many class="BoardTopic"/>
</list>
<set
name="pooledTopics"
lazy="true"
inverse="true"
where="category = 'V'"
>
<key column="board_id"/>
<one-to-many class="BoardTopic"/>
</set>
</class>
When using a simple Session.get() on the Board class, the following
SQL statements are executed:
Code:
[java] 5649 DEBUG hibernate.SQL|
select ...
from t_topic standardto0_
where standardto0_.category = 'S' and standardto0_.board_id=?
[java] 5680 DEBUG hibernate.SQL|
select ...
from t_topic pooledtopi0_
where pooledtopi0_.category = 'V' and pooledtopi0_.board_id=?
[java] 5691 DEBUG hibernate.SQL|
select ...
from t_topic requestedt0_
where requestedt0_.board_id=?
Otherwise, when the 'where' is removed from the mapping, then lazy loading works as expected (e.g. only the first select is executed).
Is this a Bug, Limitations, Feature or maybe a wrong mapping ?
...roland
Hibernate version: 3.1RC3