Does REPEATABLE READ affect Hibernate Expectations?

152 views Asked by At

We have been facing StaleStateException in our code mostly with following error Hibernate - Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1.

This error wasn't seen when we were using Oracle 12c database but it started frequenting only after migration to PostgreSQL 12.1.

Going through the following article, I have found that:

  1. Oracle doesn't support repeatable reads - I suppose it means that the new value that would be read by Hibernate will be the latest committed value in the Oracle DB at that instant of time, rather than the committed value that is read during the beginning of the transaction. Am I right?

  2. Postgres supports repeatable reads - I suppose that it means if we read a value at the beginning of the transaction, we get a committed value at that instant of time and whenever we perform the read throughout the same transaction, then we get the same value until the transaction is committed, even if a new value is committed to the database after the initial read. Am I right again?

  3. I suppose that verification of expectations come after the commit. Isn't it?

So, my question is.. Does expectations of Hibernate differ in these cases (postgres, oracle)? i.e. the expected row counts has any thing to do with presence/absence of Repeatable Reads?

Are there any other possible causes for StaleStateException not occurring in Oracle but only in PostgreSQL?

0

There are 0 answers