Quote:
I expect that the 2nd level cache will hide updates by applications that dont use hibernate to interact with the database
Read from DB (X = 1)
Put into Cache2 (X = 1)
Read from Session (read from Cache2) (X = 1)
meanwhile... some other JDBC app updates X=2
The 2nd level cache will contain X=1 until the cache decides that the value should be removed from the cache. (timeout, etc). This is correct semantics.
Other methods of indicating that it should be removed from the cache are swarmcache invalidation, whatever TreeCache uses.... and various plays on Timeout parameters of other non-clustered caches.
I am sure that other JDBC apps could update the DB and the 2nd level cache would _not_ 'see' this change until its cached copy is 'timed out' or removed for some reason. In swarmcache's case, the copy will _never_ be removed... (there are probably timeout options i'm missing, so never is probably too strong a word).
Everything must use the same 2nd level cache or there are issues...
The same issue exists between 1st level cache and 2nd level cache.
If it were possible to know that something has changed in the DB then you could update the 2nd level cache. Likewise - If you could know that something changed in the 2nd level cache then you could make information available to the session (1st level cache).
Its obviously _bad_ to change stuff in the session cache without the application knowning. Transaction consistancy, etc, etc. Which is why sessions should be shortlived.
... then i'd be able to make a long lived session.
gtg[/quote]