-->
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.  [ 6 posts ] 
Author Message
 Post subject: Lazy select
PostPosted: Wed Aug 16, 2006 9:58 am 
Newbie

Joined: Wed Aug 16, 2006 9:54 am
Posts: 3
Hibernate version:3.1.3

Is there a way to run a query and get the result list as a lazy collection?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 16, 2006 10:05 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
I doubt that this is possible.. Why would you want to do that?

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 5:08 am 
Newbie

Joined: Wed Aug 16, 2006 9:54 am
Posts: 3
I would like to get the size of the returned collection using Hibernate Filter, but the same hql later could be used for retrieving the collection itself


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 6:15 am 
Expert
Expert

Joined: Thu Sep 22, 2005 10:29 am
Posts: 285
Location: Almassera/Valencia/Spain/EU/Earth/Solar system/Milky Way/Local Group/Virgo Supercluster
You can get a lazy Iterator.

Interface Query
Code:
public Iterator iterate()

Entities returned as results are initialized on demand. The first SQL query returns identifiers only.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 17, 2006 6:57 am 
Newbie

Joined: Wed Aug 16, 2006 9:54 am
Posts: 3
Iterator is not suitable. Unfortunately, i can't use Iterator to get the size of collection, and i can't create a Filter based on an Iterator.
I also can't use Criteria approach, because my hql is constructed dynamically.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 04, 2006 4:55 am 
Beginner
Beginner

Joined: Sun Jan 22, 2006 6:56 am
Posts: 29
From the hibernate docs:

Quote:
You can find the size of a collection without initializing it:

( (Integer) session.iterate("select count(*) from ....").next() ).intValue();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.