You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by James Cerezo <ja...@cambria.com> on 2002/02/21 06:30:19 UTC

Side-effect of calling Criteria.toString()

For Turbine 2.x (don't know about 3.x):

It appears Criteria.toString() has a side-effect: the limit and offset
fields are cleared after the method call.

Examples:

// this works as expected
Criteria crit = new Criteria();
crit.setLimit(5);
Vector objs = SomePeer.doSelect(crit); // returns max 5 rows

// this example clears the limit field
Criteria crit = new Criteria();
crit.setLimit(5);
String debug = crit.toString(); // say, for example, you want
					  // to log the criteria created
Vector objs = SomePeer.doSelect(crit); // returns full rowcount


This is due to the fact that Criteria.toString() calls
BasePeer.createQueryString() and BasePeer.createQueryString() at times calls
Criteria.setLimit() and Criteria.setOffset(). Sorry, I'm not that familiar
with the code yet to suggest a patch, but it seems logical that
BasePeer.createQueryString() shouldn't mutate the Criteria parameter.

James


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>