OJB *must* lookup the db during the second query because: - there could be new data matching the query! - Maybe the user removed some objects from the cache - Maybe the Garbage collector or some cache mechanism emptied the cache
But the good news: If there are objects found in query, that are already in the cache, OJB does not materialize them from the DB (unless you set refresh="true"), but looks them up from the cache.
Try to measure the execution time of both queries. You'll see the second execution will be faster due to the cache!
cheers, Thomas
Emmanuel Dupont wrote:
All,
Here is my code
// Criterias...
Criteria crit = new Criteria();
crit.addEqualTo(Alt_log.LOG_ID_PK,"Essai" );
Query q = QueryFactory.newQuery(Alt_log.class, crit);
// Start the Db transaction
broker.beginTransaction();
altLogEdited = (IAlt_log)broker.getObjectByQuery(q);
tx.lock(altLogEdited, JwtTransaction.READ);
altLogEdited = (IAlt_log)broker.getObjectByQuery(q);
// Release the db connection to PoolConnection manager....
broker.commitTransaction();
tx.commit();
The getObjectByQuery method execute on the both calls a Select in the Database.
I don't put "true" in the class_descriptor "refresh" option
For me, OJB should'nt look to the database on the second call ...isn't it ????
Tx !
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
