【发布时间】:2015-07-24 12:50:16
【问题描述】:
如何为我的 Spring Boot 应用程序中的所有会话设置 FlushMode.ALWAYS?
最好在application.yml 中有这个设置。
更新
我在 application.yml 中都尝试过:
spring.jpa.properties.org.hibernate.flushMode: ALWAYS
spring.jpa.org.hibernate.flushMode: ALWAYS
但是下一个代码:
Session ses = factory.openSession();
ses.setFlushMode(FlushMode.ALWAYS);
LOG.debug("!!!Session.FlushMode = " + ses.getFlushMode());
LOG.debug("!!!NewSession.FlushMode = " + factory.openSession().getFlushMode());
给予:
DEBUG 47225 --- : !!!Session.FlushMode = ALWAYS
DEBUG 47225 --- : !!!NewSession.FlushMode = AUTO
【问题讨论】:
-
可以尝试添加如下spring.jpa.org.hibernate.flushMode=ALWAYS(当然是yml格式)。
标签: java spring spring-boot hibernate jpa