jdaugherty commented on code in PR #15425:
URL: https://github.com/apache/grails-core/pull/15425#discussion_r2841335784
##########
grails-data-hibernate5/grails-plugin/src/main/groovy/org/grails/plugin/hibernate/support/GrailsOpenSessionInViewInterceptor.java:
##########
@@ -73,6 +120,46 @@ public void postHandle(WebRequest request, ModelMap model)
throws DataAccessExce
session.setHibernateFlushMode(FlushMode.MANUAL);
}
}
+
+ for (AdditionalSessionFactoryConfig config :
additionalSessionFactories) {
+ SessionFactory sf = config.sessionFactory;
+ SessionHolder additionalHolder = (SessionHolder)
TransactionSynchronizationManager.getResource(sf);
+ if (additionalHolder != null) {
+ Session additionalSession = additionalHolder.getSession();
+ try {
+ FlushMode additionalFlushMode =
additionalSession.getHibernateFlushMode();
+ boolean additionalIsNotManual = additionalFlushMode !=
FlushMode.MANUAL && additionalFlushMode != FlushMode.COMMIT;
+ if (additionalIsNotManual) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Eagerly flushing additional
Hibernate session");
+ }
+ additionalSession.flush();
+ }
+ }
+ finally {
+ additionalSession.setHibernateFlushMode(FlushMode.MANUAL);
+ }
+ }
+ }
Review Comment:
Couldn't that integrity problem exist only with 1 datasource though?
Shouldn't the other still save?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]