1
0
mirror of https://github.com/google/nomulus synced 2026-01-06 13:36:48 +00:00

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 68fc4cd022
commit 045de3889b
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));
}