I work in a software product company, and we use hibernate in our java based application . The application is a smart-client based application where each client is itself a jvm . We were using our proprietary cache bor both client and server side now , but want to replace the server side cache with a cache solution that supports clustering.
Now we are trying to use ehcache as the hibernate second level cache and trying to know if we can replace our current cache with it . But some technical problems are coming up. The client tries to read our objects mainly based on its date fields which obviously is not a unique key . In our current in memory cache , we were maintaining a date list
to make the server side program know, which objects are there in the cache. eg. If client wants to read all objects with date as Feb 16 2008, the server side program checks if the date is included in the date list and if included, it simply loops through the object arraylist stored to filter out the needed objects. So database hit is avoided.
But, I think that in hibernate, if I query for objects with non-id field it anyway would search in the database (kindly do not consider the query level cache, but only the cache of persistent objects). Is there any way, to query the ehcache so that it only gives all the objects in the cache only , without going to database. i.e I want to force hibernate to look into the cache only , as I can make my objects stored in ehcache eternal, and know that if the datelist has the requested date, then I have all the objects
corresponding to it already in cache?
|