如何为Spring Boot应用程序设置org.hibernate.org.hibernate.FlushMode?

时间:2015-05-13 09:53:14

标签: java spring hibernate spring-boot flush

如何在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

1 个答案:

答案 0 :(得分:5)

您需要添加以下属性:

spring.jpa.properties.org.hibernate.flushMode=ALWAYS