Relative Content

Tag Archive for hibernatecaching

What’s Hibernate cache invalidation mechanism?

Consider two users Alex and John. Both request the same Contract object contract1 simultaneously. contract1 is then cached in 1st level cache in both Alex’s and John’s sessions. Alex starts a transaction and makes a change to contract1 and commits it. What happens to John’s contract1 if John queries contract1 again right after Alex commits his update? How does Hibernate detects that contract1 in John’s 1st level cache is inconsistent with its respective state in the database? Remind you the 2nd level cache is disabled (by default).