R – Transactional L2 cache in Hibernate


What does "transactional" strategy guarantee?

What is the difference between "transactional" strategy and "read/write" strategy with JTA as transaction manager (specified by property).

What if I specify "transaction" strategy for some entity in a .hbm.xml file and then will use L2 cache which does not support "transaction" strategy.

Best Solution

For Q1 - Transactional means two things in my understanding. If you have synchronous replication, your transaction will pause until all nodes get the replicated change. if you have asynchronous replication, you can be sure that your other nodes will see the changes in the isolation level chosen (e.g. read committed) and will comply with commits and role backs. It also means that if an error occurred in the database, or another exception thrown (causing a rollback in case of a transactional aspect on the caller) the cache will also perform a rollback to the changes - keeping a synchronization between cache and database. note that this requires a JPA transaction manager.

For Q2 - Read/Write is not cluster safe, it doesn't guarantee data consistency between nodes

For Q3 - Never tried, but it will probably fail with a nice Exception

Related Question