Hi,
We are developing a rich client (swing) on a client-server architecture (2-tier), and I decided, with Emmanuel's approval (
http://forum.hibernate.org/viewtopic.php?t=930418), to use a single session for the whole application lifecycle.
I know I have to be careful at managing the session (calling evict
() for instance). I'll use optimistic locking to address concurrency (when saving).
The main reason I want to use a single session is for the == JVM equality, on domain objects, guaranteed through its whole life. I guess this is handled by the Identity Map design pattern.
May I use the identity map without caching objects? In other words, each time something is queried through Hibernate's session, I would like it to actually query the database without checking the cache but checking its identity map.
This would ensure that each time I query objects from Hibernate, I receive fresh copies of unknown objects, and the one in the identity map would be simply updated. Then I would update all views (observers) attached to these objects (MVC design pattern for the presentation layer).
Can I ask hibernate to do the same when fetching objects through a domain object relation? (ie. animal.getRegions() ).
If there's a way to turn off caching still ensuring object == JVM equality with the identity map, that would be perfect.
Thanks