Hi everyone, this is my first visit, definitely not the last.
I've got a wine table with a set of wineFoodGroups, the hbm.xml section looks like this:
<class name="za.co.thewinelist.model.Wine" table="wine">
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<property name="description" length="1024"/>
<many-to-one name="user" not-null="true"/>
<many-to-one name="varietal"/>
<property name="price"/>
<property name="winery"/>
<property name="vintage"/>
<property name="award"/>
<property name="rating"/>
<property name="created" type="timestamp"/>
<set name="wineViews" inverse="true" cascade="all-delete-orphan" lazy="true">
<key column="wine"/>
<one-to-many class="za.co.thewinelist.model.WineView"/>
</set>
<set name="wineListWines" inverse="true" cascade="all-delete-orphan" lazy="true">
<key column="wine"/>
<one-to-many class="za.co.thewinelist.model.WineListWine"/>
</set>
<set name="wineFoodGroups" table="WineToFoodGroup" cascade="all">
<key column="wine"/>
<many-to-many column="foodGroup" class="za.co.thewinelist.model.FoodGroup"/>
</set>
in my JavaAction I'm doing the following:
Query query = session.createQuery( "select wine from za.co.thewinelist.model.Wine wine " +
"where wine.varietal = :varietal " +
"and :foodGroup in elements( wine.wineFoodGroups ) " );
query.setString( "varietal", searchVarietalId );
FoodGroup fdGroup = (FoodGroup)session.load( za.co.thewinelist.model.FoodGroup.class, foodGroupId );
query.setEntity( "foodGroup", fdGroup );
This does not work, I'm new to hibernate and would appreciate any help.
Thanks
|