Hibernate has a first and an optional second level cache. The first level cache is mandatory and it's one storing your attached Entities that are to be synced with the DB.
So at flush time, the 1st level cache and the current db transaction are in sync, while at commit time the changes are propagated to other connections as well.
The 2nd level cache comes in many flavours:
- read-only (never updated)
- nonstrict-read-write (there is no cache lock, so when two competing transactions are modifying the same entry, it's not clear who wins)
- read-write: similar to a READ_COMMITED database isolation level.
- transactional: The cache will be enlisted in the current JTA transaction
Some implementations are also clustered and have additional sync options.
The more safe the sync mode the less performance you'll get, so make sure you choose the right one for your application use cases.