----- 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
one
> 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
Hi,
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.
BW,
Andras.
|