When second level caching is enabled with Hibernate, it seems to have a lot of limitations like the information from the cache can be queried only using the primary key and usage of joins.
I think this seriously limits the advantages of using 2nd level cache unless we are querying for something that changes rarely. Most of the times, there will be a requirement to query the database on several criteria, not just primary key and also there may be several lazy associations for the table which needs to load.
So the caches like Ehcache etc don't seem to solve this problem. Are there any frameworks which solve this problem?
Like I can load certain range of a database table into a cache and use it for some time from the cache before invalidating and reloading the information again from the database?