Objects are "dehydrated" before being stored in cache, meaning individual properties (including associations) are turned into serialized objects. When an object is loaded from cache, it is "rehydrated" into a regular POJO (or a proxy to it).
This way to concurrent sessions accessing the 'same' object are actually accessing two separate instances (both rehydrated from cache).
So question 1 : A is stored to cache, A's Bs are stored to their cache region, and so is C. A dehydrated state containts C's ID.
question 2 : if a 1-n or m-m is relation is cached, only the association is cached, not the objects themselves. So If A as many Bs and the A to B relation is cached, and if you the Bs have been expired from cache, calling A.getBs() will end up in one request for each individual B.
Disclaimer : I've not read not understood nor written Hibernate's whole code so I might be wrong. If a guru reads this and if I'm wrong, feel free to flame me :)
|