I wrote that code :)

so, if your driver/db combo support cursoring, setting the begin and end index will 
allow you to just display a window of results. The efficiency is based on the db, but 
it's worked for us on SQL Server and Oracle so far.

OJB will execute the query, then use the cursor to jump to the startAtIndex. It will 
iterate through the results, inflating/retrieving the objects until endAtIndex is 
reached( or you run out of results) , then it will return.

hth,
Matthew

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, March 24, 2003 8:52 AM
To: [EMAIL PROTECTED]
Subject: A smart way to set maximum number of records returned by a
Query (ORACLE)


Hi,

Can someone explain me what the Query.setStartAtIndex() and
Query.setEndAtIndex() are actually doing ?
>From what i have picked up, it is not intented to be used when you want to
prevent the DB engine from retrieving huge numbers of results.

I have tables that can contain hundreds of thousands of records.
When a user select no search criteria in my query interface, I would like
to prevent OJB from creating huge number of Objects (to save memory and
time !).
I would rather like to be able to set a maximum size for the returned
Collection.

The only trick I found is to add to my Query a SQL criteria like this :

Criteria crit = new Criteria();
crit.addSql("rownum < 100");
Query q = QueryFactory.newQuery(Foo.class, crit);
Collection c = broker.getCollectionByQuery(q);

Ok, it is not very smart and works only for Oracle...
Anybody has a better idea or could tell me if that is doable with
Query.setStartAtIndex() and Query.setEndAtIndex() ?

Thanks,

Thomas



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


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

Reply via email to