Quote:
If one of the regions gets updated then I guess that change wont be reflected in the other cache region? Is my understanding correct??
Yes.
In practice it is indifferent in which regions you store entities or collections,
but there's one particular think to pay attention:
you should configure the regions in a way that entities do never expire before the collections which refer to this entities.
Example:
Scenario 1:
- you call a.getAllB();
- the association collection and the target B entities are all present in 2L cache
This is the perfect scenario, no database hit.
Scenario 2:
- you call a.getAllB();
- the association collection is present in 2L cache but some of the B entities which are referred by the collection
are no more present in 2l cache (already expired).
In this case Hibernate wlll issue single sql-statements in order to load the missing entities again into the caches.
Now Instead to have 0 or 1 database-hit loading the association, you can have up to <n> database hits! (where n is the size of the collection)