mirror of
https://github.com/google/nomulus.git
synced 2025-07-25 12:08:36 +02: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:
parent
fe0c37eee6
commit
1f0cd80556
2 changed files with 5 additions and 4 deletions
|
@ -141,14 +141,15 @@ public class JpaTransactionManagerImpl implements JpaTransactionManager {
|
||||||
// Postgresql-specific: 'set transaction' command must be called inside a transaction
|
// Postgresql-specific: 'set transaction' command must be called inside a transaction
|
||||||
assertInTransaction();
|
assertInTransaction();
|
||||||
|
|
||||||
EntityManager entityManager = getEntityManager();
|
ReadOnlyCheckingEntityManager entityManager =
|
||||||
|
(ReadOnlyCheckingEntityManager) getEntityManager();
|
||||||
// Isolation is hardcoded to REPEATABLE READ, as specified by parent's Javadoc.
|
// Isolation is hardcoded to REPEATABLE READ, as specified by parent's Javadoc.
|
||||||
entityManager
|
entityManager
|
||||||
.createNativeQuery("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ")
|
.createNativeQuery("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ")
|
||||||
.executeUpdate();
|
.executeUpdateIgnoringReadOnly();
|
||||||
entityManager
|
entityManager
|
||||||
.createNativeQuery(String.format("SET TRANSACTION SNAPSHOT '%s'", snapshotId))
|
.createNativeQuery(String.format("SET TRANSACTION SNAPSHOT '%s'", snapshotId))
|
||||||
.executeUpdate();
|
.executeUpdateIgnoringReadOnly();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,7 +206,7 @@ public class ReadOnlyCheckingEntityManager implements EntityManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query createNativeQuery(String sqlString) {
|
public ReadOnlyCheckingQuery createNativeQuery(String sqlString) {
|
||||||
return new ReadOnlyCheckingQuery(delegate.createNativeQuery(sqlString));
|
return new ReadOnlyCheckingQuery(delegate.createNativeQuery(sqlString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue