Hibernate version:
3.1
Hi. I've recently started experiencing with second level cache in hope to improve my app performance. I'm using ehcache and enabled usage of second level cache and query cache in configuration file.
In general, my application contains several simple POJOs, and for simplicity lets assume they have primitive properties only (that is, no collections, references, etc)
I need a way to cache my entities not necessarily by their id. I understand that the only way to use a non-standard (i.e. not entity id) key for cache lookups is to use query cache (am I wrong? Is there a method in which I can specify different cache indexing?). Unfortunetly, I've noticed that the key that hibernate inserts to the cache in this case is comprised of the entire query string (!) + the query parameters. Together with all other information stored in each cache entery by ehcache, this makes this feature completely infeasible for me, as I have many combinations of parameters.
Any suggestions? Is there a better practice to achieve this?
thanks
|