Hi Dave, Dave Hodson wrote:
> 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'"? I think maybe Charles answered this already, but to reiterate that the short answer is that you can't get objects from the OJB cache unless you use the Identity as the key. It's the same as with any Map/hashtable etc, ie you can only get at particular objects via their single key. The only way to access a cached object without going through its Identity is basically (as I think Charles also mentioned) to implement your own cache and key it on whatever unique criterion other than Identity you wish to use. We have a similar requirement on our project, and ended up having our own extra cache. Bit of a pain, as the object usually exists in the OJB cache but you can't get at it if you don't have the Identity (which you can only build based on PKs) so you end up duplicating things. I can't help feeling there is a better solution, maybe some kind of cache partitioning based on different key objects, but I don't have time to think about that just now (and I'm probably not smart enough anyway...). Cheers, Chris -- To unsubscribe, e-mail: <mailto:ojb-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>
