db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Eade <se...@backstagetech.com.au>
Subject Re: Count(*) and criteria
Date Mon, 03 Feb 2003 10:18:40 GMT
On 3/02/2003 8:53 PM, "peter riegersperger" <rick@subnet.at> wrote:
> 
> Criteria crit = new Criteria();
> [add some conditional expressions with criteria.add(...)]
> Criteria myCrit = (Criteria)crit.clone();
It seems that Criteria does not implement Cloneable or clone() so I guess it
would be necessary to create a second criteria from the beginning and set it
up to be the same as the original (yuck).
 
> List myList = MyPeer.doSelect(crit);
> 
> myCrit.addSelectColumn("SELECT Count(ID)");
This would have been:
  myCrit.addSelectColumn("count(ID)");
But it won't work anyway because the crit cannot be cloned.
> List myCountList = MyPeer.doSelect(crit);
>
[...]
>> LargeSelect may obviate the need to do the count(*) as it provides an
>> indication of the length of the result set as the query progresses, e.g. it
>> might say that it is displaying page 1 of > 25 indicating that there are
>> more than 25 pages of data available.
> 
> i looked at the javadoc, and it sounds like what i need.
> in the doc, it is stated that LargeSelect should be stored in the session. How
> big is the performance impact of re-creating it each time (and then hopping
> to the requested page)?
The whole point is that you are not recreating it each time - it is there in
the session with the chunk of data that the user is paging through.  One
thing I do with LargeSelect is attempt to ensure that the object is removed
from the session as soon as the user goes down a different path in the
application.
> personally, i hate putting anything in the session and i try to avoid it as
> much as i can.
It is good to be cautious about putting things in the session, but it exists
for a reason and is put to good use by LargeSelect.  I use it and it works
well (I am biased because I contributed heavily to it).
> 
> many thanks for your help,
> 
> rick

Cheers,

Scott
-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au
.Mac Chat/AIM: seade at mac dot com


Mime
View raw message