Section
7.2 of the Hibernate reference manual says that you can add an arbitrary SQL where clause to control what elements of a collection are returned:
Quote:
where (optional) specify an arbitrary SQL WHERE condition to be used when retrieving or removing the collection (useful if the collection should contain only a subset of the available data)
I have a mapping that uses this:
Code:
<set name="children" inverse="true" cascade="all"
access="field" order-by="sort" where="deleted=0">
<key column="parent_id" />
<one-to-many class="ProductCategory" />
</set>
"where" is definitely part of the DTD and is supposed to be valid for a set mapping. And yet when I try this, it appears to have no effect. In my testing it wasn't working and so I started looking at the generated SQL and didn't find the where clause.
Next I added a nonsense condition that doesn't match my table or object structure at all and which should have caused an error (where="foobar=0"). On testing "foobar" doesn't appear in the generated SQL, nor does Hibernate ever throw any errors when this mapping is used.
This behavior happens under the current 3.1 release candidate as well as an older CVS snapshot of 3.1 I had. I can't easily test under 3.0 because my app has 3.1-specific functionality.
Is the documentation incorrect, 3.1 broken, or am I missing some way to turn this functionality on? Thanks.