Is it possible to change the 2nd-level (entity) caching used for a particular query? For most work, I want Hibernate to cache as I specified in the xml files. But there are a few queries where I need much tighter control (I'm in a clustered environment, and would like to get to guarantee that I'm reading correct data (clustered environment), and/or serializable isolation).
Something like this:
Code:
session.createQuery("from Foo").setCachedEntities(false).list();
Then I could get what I want without creating another session. Most of the time I'd only need this for fetching entities by ID, but occasionally it would be really helpful for full queries.
Such a system would read the entities into the L2 cache to insure that the application was consistent, too.
Thoughts?