db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andras Balogh" <j...@reea.net>
Subject Re: How to get specified number of entries?
Date Mon, 17 Mar 2003 09:32:24 GMT

----- Original Message -----
From: "Michael Schmitt" <mi.schmitt@gmx.de>
To: <torque-user@db.apache.org>
Sent: Sunday, March 16, 2003 15:05
Subject: How to get specified number of entries?

> Hi,
> I want to do something like 'Give me the first twenty entries from mytable
> and tell me if there are any more entries, or better: additionally tell me
> how
> many entries there are in the table. If possible, all of this with only
> criteria (one select, one db-connection, well, in the end as fast as
> possible)'.
> Just now, I don't even know how to get the number of entries without
> reading all the entries. Something like:
> ItemPeer.doSelect(new Criteria()).size();
> Any ideas?
> bye,
> michael


Another solution (not so good) would be to use limit and offset properties
of the Criteria.
You could retrieve n+1 values (ex. 20+1) all the time to know that you  have
more values
 ahead or not. (if you need to add previous, next links)
Like this you don't know actually how many values you have
 (this can be obtained with another Criteria) but you know that you have
more in front or not.



View raw message