nerotnt wrote:
1) If we have a session cache level and supposing I have session instance per method, then where are the cached objects so they can be used between sessions?
In case of a Hibernate transaction that associates a database transaction with a ThreadLocal Session (like implemented by the Spring Framework), all data access methods that participate in a transaction will share the same Session. But generally, the Session is a means for consistency rather than long-term caching in the typical sense.
nerotnt wrote:
2) If the cache is never aware of changes made to the persistent store by another process, then we could be accessing old data. Even with a small expire time there could be the possibility a process can access old data. But if we put a small expire time for the cache, then what is the cache good for if the cached objects expire quickly.
That's of course true for a JVM-level cache, and represents the typical tradeoff when using a cache. But for the Session-level cache, you can avoid staleness of data by setting a proper database transaction isolation level, provided that the scope of your transaction matches with the lifetime of your Session.
Juergen