A follow up:

I don't think the executeQuery method below calls
Torque.release(DBConnection) on the DBConnection that's passed in.  To
prevent Torque from exhausting your connection pool, the code should be:

...
TransactionPeer.addSelectColumns(criteria);
criteria.addAscendingOrderByColumn(TransactionPeer.AS_OF_DATE);
DBConnection connection = Torque.getConnection();
List transactionRecords =
TransactionPeer.executeQuery(TransactionPeer.createQueryString(criteria), 
offset, 
limit, 
false, 
connection);
transactions = TransactionPeer.populateObjects(new
Vector(transactionRecords));
Torque.releaseConnection(connection);
...

Cheers,
Dave

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] 
Sent: Friday, May 24, 2002 5:44 PM
To: [EMAIL PROTECTED]
Subject: RE: How to limit a query?

Doing that might make me wonder why it is again I'm using Torque in the
first place.  This is more like what I had in mind,

...
TransactionPeer.addSelectColumns(criteria);
criteria.addAscendingOrderByColumn(TransactionPeer.AS_OF_DATE);
List transactionRecords =
TransactionPeer.executeQuery(TransactionPeer.createQueryString(criteria), 
offset, 
limit, 
false, 
Torque.getConnection());
transactions = TransactionPeer.populateObjects(new
Vector(transactionRecords));
...

, where 'criteria' contains a representation of my 'WHERE' clause, and where
'offset' and 'limit' are integers.

It appears the BaseXXXPeer has a generated executeQuery method (not covered
in the JavaDocs on the Torque site) that takes an offset and a limit, more
important, that this method works.  The createQueryString method on the peer
class gets me my SQL string so don't have to hand-tailor it, and the
populateObjects method on the peer class reconstitutes a Vector of Record
objects into a Vector of business objects.  At that point, I'm home free.

Cheers,
David

-----Original Message-----
From: John McNally [mailto:[EMAIL PROTECTED]] 
Sent: Friday, May 24, 2002 11:59 AM
To: Turbine Torque Users List
Subject: RE: How to limit a query?

Creating the sql as a string and passing it to xxxPeer.executeQuery()

john mcnally

On Fri, 2002-05-24 at 09:44, [EMAIL PROTECTED] wrote:
> Is there a work-around for Oracle for Torque pre-patch?
> 
> -----Original Message-----
> From: John McNally [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, May 24, 2002 9:18 AM
> To: Turbine Torque Users List
> Subject: Re: How to limit a query?
> 
> It works for some databases.  I just committed a patch for oracle so
> previous versions will not take advantage.  I believe mysql and
> postgresql support is best supported.
> 
> john mcnally
> 
> On Fri, 2002-05-24 at 08:41, [EMAIL PROTECTED] wrote:
> > Hello,
> > 
> >  
> > 
> > How do I limit a Torque select to only return a certain number of rows?
I
> > ask because I see a method on Criteria called setLimit, which takes an
> > integer.  There's no documentation I can find for it, but I guessed that
> it
> > limits the number of rows to return, except when I call it on my
Criteria
> > object just prior to calling XXXPeer.doSelect(myCriteria), it doesn't do
> > anything.  I still get back all the rows for the query.  Maybe I guessed
> > wrong.  Is there some other method or function somewhere that limits the
> > number of rows, or is this it?
> > 
> >  
> > 
> > Also, there's a method setOffset.  Again, I'm guessing that this sets
the
> > starting point within the resultset, at which point it begins returning
> > rows, which would be useful for paging.  Is this correct?
> > 
> >  
> > 
> > Thanks!
> > 
> > David
> > 
> >  
> > 
> > David A. Ventimiglia
> > 
> > Wells Fargo Private Client Services
> > 
> > (415) 396-0414 (work)
> > 
> >  
> > 
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> 
> 



--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to