Thomas Thx for the reply. Not to be too thick-headed here, but I'm not sure I understand this completely. It sounds like (for QueryByCriteria) you are saying that a SQL statement is always executed and then OJB determines whether or not the resulting Identity currently exists in the cache.
If I've correctly understood your answer, I have one more question. How can I (is it possible?) pull an object from the existing cache using criterion that is not one of the primary keys? In other words, using Tutorial 1 as an example, how can I pull from the cache without querying the database when the criteria is "NAME='Widget'"? Thx Dave > > However, it seems when I use QueryByCriteria, I get the > results, not > > from the cache, but from the database. Based on what I have read on > > the OJB website, I'm thinking that this happens > specifically because > > the criteria I'm using is not one of the db primary keys > (e.g. Using > > Tutorial 1 as an example, if I query using the NAME > column, OJB goes > > to the database to retrieve the value, but does not cache > the outcome > > so any subsequent calls with the same NAME also hit the > database, not > > the cache) > > Things are working a bit different. > If you are performing a QueryByCriteria a SQL statement > reflecting the > criteria is executed. > OJB than iterates over the corresponding resultset to materialize > objects from each row of the resultset. > Before an object is actually materialized OJB takes the primary key > information from the current resultset row and builds an > Identity from > it. OJB then looks up the cache if there is already stored an > Object for > this Identity in the cache. > If so the cached object is used. If not the object is read in > from the > resultset. > > > > > If my thoughts are correct (let me know if they are not!), > is there a > > way to cache an object retrieved from the database with a > > QueryByCriteria call, when the critieria consists of a field or > > fields that are not one of the primary keys? > > > > As mentioned above: this is already implemented. But OJB still has to > execute a full SQL statement to get the raw data. > > cheers, > Thomas > > > Dave --- Dave Hodson MessageCast, inc. Email: [EMAIL PROTECTED] > > www.messagecast.net > > > > > > Hi > > > > -- > To unsubscribe, e-mail: > <mailto:ojb-user-unsubscribe@;jakarta.apache.org> > For additional commands, e-mail: > <mailto:ojb-user-help@;jakarta.apache.org> > > --- Dave Hodson MessageCast, inc. Email: [EMAIL PROTECTED] <mailto:dave@;messagecast.net> www.messagecast.net -- To unsubscribe, e-mail: <mailto:ojb-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
