-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: One-to-many select data to object.
PostPosted: Mon Aug 09, 2010 3:08 pm 
Newbie

Joined: Mon May 11, 2009 3:15 pm
Posts: 4
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) ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.