Hi Dave, It is not possible without a database query.
The cache is soley keyed on Identity. It would be possible to create your own cache implementation to store other keys (so long as it is also keyed upon identity) - but OJB would only be to retrieve the data from the cache using Identity - if you want to look stuff up in the cache on a different key, you'd have to do it outside of OJB. HTH, Cheers, Charles. >-----Original Message----- >From: Dave Hodson [mailto:dave@;messagecast.net] >Sent: 05 November 2002 08:12 >To: OJB Users List >Subject: RE: Basic caching question > > >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> > This email and any attachments are strictly confidential and are intended solely for the addressee. If you are not the intended recipient you must not disclose, forward, copy or take any action in reliance on this message or its attachments. If you have received this email in error please notify the sender as soon as possible and delete it from your computer systems. Any views or opinions presented are solely those of the author and do not necessarily reflect those of HPD Software Limited or its affiliates. At present the integrity of email across the internet cannot be guaranteed and messages sent via this medium are potentially at risk. All liability is excluded to the extent permitted by law for any claims arising as a re- sult of the use of this medium to transmit information by or to HPD Software Limited or its affiliates. -- To unsubscribe, e-mail: <mailto:ojb-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
