Hi,
I just ran in a problem to load an object that has multiple many-to-many associations. A part of the mapping of the object Restaurant looks like:
Code:
...
<bag name="Kuechenarten" table="Restaurant_Kuechenart" cascade="all-delete-orphan" inverse="false">
<key>
<column name= "`RestaurantID`" />
</key>
<many-to-many class="Kuechenart" fetch="join" >
<column name= "`KuechenartID`" />
</many-to-many>
</bag>
...
("Kuechenart" means something like Cuisine ot style of food. )
Now I want to get all Restaurant objects that have multiple Kuechenarten, i.e. all Restaurants that offer all Cuisines that I'd like to have.
To get just one of many Kuechenarten is no problem (NHibernate/C#):
Code:
ICriteria _criteria = Session.CreateCriteria(typeof(Restaurant),"Restaurant");
criteria.CreateCriteria("Kuechenarten").
Add(Expression.In("KuechenartID", kuechenartenIDs)).SetResultTransformer(CriteriaUtil.DistinctRootEntity);
but I don't have an idea how to get all Restaurants that match all Kuechenarten with (N)Hibernate.
As I think there is no difference in an Hibernate and NHibernate solution I ask in the Hibernate forum.
Thanks,
silveraxe