emmanuel wrote:
Yes it is possible but may be dangerous.
Yes, this is what I read everywhere, however I absolutely need the == JVM equality accross all my application (multiples views).
emmanuel wrote:
You may have stale data (updated elsewhere and not refreshed in your session).
What does that actually mean? If my code modify a Domain Model Object instance, loaded and cached by the single Session, how can it be desynchronized ? I mean there's just a unique instance of it...
emmanuel wrote:
What you can do is refreshing your session from time to time (ie clearing the cache).
Calling session.evict(domain_object) when I know there are no more views attached to my domain_object would be an example of a solution?
emmanuel wrote:
And check the disconnect/reconnect feature, it rocks with 2-tier apporaches.
Thanks, I'm looking at disconnect / reconnect. I thought this was disconnecting the underlying JDBC connection, but traching in the source code, it doesn't seem to be the case.
There's a Second-Level cache. When I first read on it, I thought that was exactly what I was looking for. A global cache, ensuring == JVM equality between objects manipulated accross multiple sessions. Actually, I thought I could open session1, call session1.find(), store returned objects somewhere, close session1, open session2, call session2.find(), get some objects from the db, and some from the second-level cache (with == JVM equality), close session 2, etc....
However, I receive new object instances.
Is the second level cache supposed to handle what I've just described above? Would it be the solution to my MVC/Observer approach? If I'm receiving new instances, is it because I'm not using the cache correctly? (I'm using the EHCache...)
Thanks for your help,