I have two tables offer and image. Offer can have 3 images;
offer( id ... ) image (id, offer_id, name, ... )
NetBeans generate two hbms for me.
Offer.hbm (...) <set name="images" inverse="true"> <key> <column name="offer_id" not-null="true" /> </key> <one-to-many class="com.host.pojo.Image" /> </set>
and Image.hbm
public class Offer implements java.io.Serializable { private int id; private Set<Image> images = new HashSet<Image>(0); (...) }
criteria = DetachedCriteria.forClass(Offer.class) .setFetchMode("images", FetchMode.JOIN) ; When I tried to use criteria api to select my offers I expect that I will get one offer with set of three images inside offer object but I got three offer object as result. How can I change this?
Is any way to avoid adding third table lik offer_image ( offer_id, image_id) ?
|