Allow database comparison when in read-only mode (#1490)

Note: this change was actually authored by @weiminyu, I'm checking it in for
expediency.
This commit is contained in:
Michael Muller 2022-01-13 09:32:49 -05:00 committed by GitHub
parent fe0c37eee6
commit 1f0cd80556
2 changed files with 5 additions and 4 deletions

View file

@ -141,14 +141,15 @@ public class JpaTransactionManagerImpl implements JpaTransactionManager {
// Postgresql-specific: 'set transaction' command must be called inside a transaction
assertInTransaction();
EntityManager entityManager = getEntityManager();
ReadOnlyCheckingEntityManager entityManager =
(ReadOnlyCheckingEntityManager) getEntityManager();
// Isolation is hardcoded to REPEATABLE READ, as specified by parent's Javadoc.
entityManager
.createNativeQuery("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ")
.executeUpdate();
.executeUpdateIgnoringReadOnly();
entityManager
.createNativeQuery(String.format("SET TRANSACTION SNAPSHOT '%s'", snapshotId))
.executeUpdate();
.executeUpdateIgnoringReadOnly();
return this;
}

View file

@ -206,7 +206,7 @@ public class ReadOnlyCheckingEntityManager implements EntityManager {
}
@Override
public Query createNativeQuery(String sqlString) {
public ReadOnlyCheckingQuery createNativeQuery(String sqlString) {
return new ReadOnlyCheckingQuery(delegate.createNativeQuery(sqlString));
}