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: Extra lazy initialization of a collection by query?
PostPosted: Mon Oct 16, 2006 9:46 am 
Newbie

Joined: Mon Oct 16, 2006 9:18 am
Posts: 4
I found some similar posts regarding this issue but no satisfatory answers. Is it possible to return an extra-lazy collection from a query? My use case is e-mails. I may want to show the number of, say, new messages from my contact list upon login. However, I have no need at that point to show any actual message subject, body, etc.

I know I can issue a count query and obtain the count without initializing any message collection. However, this will force callers of my message retrieval code to use two different methods to either get the actual collection or get the count. These two different methods will have very similar select queries that I would rather consolidate.

In short, I would like for the caller of my code to execute one single method:

List<Message> messages = magicCode.getMessages(UNREAD+FROM_CONTACTS); // this issues an HQL query
int count = messages.size();

In other words, the message collection needs to be extra lazy here.

If member collections can be extra lazily retrieved, why can't collections based on queries have the same capability?

Thanks.


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.