mirror of
https://github.com/google/nomulus.git
synced 2025-07-24 03:30:46 +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
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue