-->
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.  [ 3 posts ] 
Author Message
 Post subject: deeper fetch collections
PostPosted: Thu Aug 05, 2004 4:14 pm 
Hello,

I have a question about fetch sql collection. For my domain model, I have a Event, which has a Set of Market; Market has a Set of order. Can I get all these Sets by fetch sql? We know that using
"from Event event left join fetch event.markets where eventId=?" can give us the Event with initialized Set of markets. Can we get a Set of order from each market within fetched event.markets Set? I know for join fetch we can just get one collection, but here I need to get deeper collection within the objects graph.

Any help is appreciated.

Min


Top
  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 4:17 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, you will have to execute another query (many queries, in fact). This might be unfortunate if you have not many Markets and Orders, but keeping the outer-join fetched resultset small is a good choice as soon as you have more than a few rows (say, more than 500 in each table).

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 4:46 pm 
Hi Christian,

Thanks for reply. So if Event has other Sets like Ticket, then we need to provide another method as Event e1 = getEventWithTickets(eventId) in the DAO along with Event e2 = getEventWithMarkets(eventId) to initialize different Set. Can we merge these two events e1, e2 so one of them have all the Set initialized by like e2.setTickets(e1.getTickets())?

Another question is about the data structure returned to web tier. If the objects graph is complex, is it a good idea to provide another POJO to contain these relations? For example, Event has Set of Markets (which is loaded by join fetch), each Market has a Set of Orders, what is a good way to model this data structure so web tier can display it directly? Have you had this kind of situation before?

Thanks.

Min


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

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.