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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user