I am a new user of Hibernate:
Following on from 'Nearly impossible to synchronize properly in Hibernate', with slightly different questions:
To restate, optomistic locking is best, but deadlocks or stale objects exceptions must be detected, caught and (probably) re-tried. Are these obvious Hibernate exceptions which can be caught directly?
I have a very large data set (across 5 tables) that I want to keep in
memory for improved performance and regular accesses, with a prinicpal parent table, and a number of child tables.
By caching the parent and children objects, will multiple sessions access the SAME physical object, or copies of that object? Do all child collections remain the same physical objects or different collections, containing the same (cahced) objects?
If two threads (from http servlets) attempt to access a child relation 'at the same time', what occurs? Does the single collection object get updated by both threads?
If >1 thread can access the same collection object, this may cause concurrent modification exceptions on any iterators on the base collection. This would be a BAD thing.
If each thread has different physical objects/collections, how does initialised collections (from the cache) get copied into each thread's version of the collection without re-querying the database. Requerying would be a BAD thing as the collection is large, and most data is needed.
If caching a parent object, when would the child object collections be updated with results from multiple threads? Equivalent to read-dirty, read-committed and other isolation levels. Obviously, in my scenario, I would not expect to continuously re-query the child collection from the database to detect the latest child objects.
I think a general document providing Hibernate guidelines for multi-threading operations would be very useful!
Thanks.
|