[quote="farzad"][quote="wiphillyfan"]I'm wondering if the Query Cache would help you - you might want to look into that. I found this good read:
http://www.javalobby.org/java/forums/t48846.html[/quote]
Query cache is indeed a solution but a better solution would be fetching database ids instead of entities. The reason behind this is that a query cache is thrown away if hibernate detects any update in any participating entities in a query so updating a single entity will result in hitting the database and fetching the whole object graph. Retrieving ids is minimal and combined with a query cache gives the ultimate performance.
Farzad-[/quote]
Dear Farzad
Thanks a lot for the reply. But I am afraid that I probably could not make my doubt clear.
1) I am not looking for the query cache as a solution as my database tables get updated too quickly to get benefit from it
2) I am fine with fetching objects with ids. But in our application the client wants to read objects based on their Date fields, which are certainly non-unique non-id property fields.
My problem more precisely is:
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?