I am using the archetypal method of returning the count of a collection without initialization in order to return a total SKU count:
Code:
((Integer)session.filter(review.getSkus(), "SELECT
COUNT(*)").iterator().next()).intValue();
This is many-to-many, and works beautifully. (tables: review, part, review_part).
Code:
<set name="parts" table="review_part" inverse="false" lazy="true" >
<key column="review_id"/>
<property name="state" type="int" column="state"/>
<many-to-many class="Part" column="part_id" />
</set>
Now I would like to return a count of SKU's that have proposed prices which have not been approved yet. To simplify the design, I've added state to the many-to-many review_part table. Instead of drilling threw review->part->price->price_change.state, I can just query the state from the association directly-cleaner design pehaps.
So I create an object called ReviewPart, which consists of a part and a state and belongs to a review, I've changed the mapping to:
Code:
<set name="parts" table="review_part" inverse="false" lazy="true" >
<key column="review_id"/>
<composite-element class="ReviewPart">
<property name="state" type="int" column="state"/>
<many-to-one name="part" class="Part" column="part_id" />
</composite-element>
</set>
And this doesn't work, because:
QueryException: collection of values in filter: this
Hibernate version: 2.1.2
I've read the FAQ that suggests using this technique, and the threads that discuss limitations of the current version. So how do you address this now? Is there a workaround?