Propagate read-only status through Session.setDefaultReadOnly(true)

Issue: SPR-16956
This commit is contained in:
Juergen Hoeller
2018-07-03 22:22:19 +02:00
parent 0b86c71b2a
commit d22d408261
2 changed files with 29 additions and 18 deletions

View File

@@ -495,6 +495,8 @@ public class HibernateTransactionManager extends AbstractPlatformTransactionMana
if (definition.isReadOnly() && txObject.isNewSession()) {
// Just set to MANUAL in case of a new Session for this transaction.
session.setFlushMode(FlushMode.MANUAL);
// As of 5.1, we're also setting Hibernate's read-only entity mode by default.
session.setDefaultReadOnly(true);
}
if (!definition.isReadOnly() && !txObject.isNewSession()) {