PaintedRed
PaintedRed

Reputation: 1418

How to set up org.hibernate.org.hibernate.FlushMode for a Spring Boot application?

How can I setup FlushMode.ALWAYS for all sessions in my Spring Boot app? It would be nice to have this setting in application.yml.

UPDATE

I tried with both in application.yml:

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

However next code:

    Session ses = factory.openSession();
    ses.setFlushMode(FlushMode.ALWAYS);
    LOG.debug("!!!Session.FlushMode = " + ses.getFlushMode());
    LOG.debug("!!!NewSession.FlushMode = " + factory.openSession().getFlushMode());

gives:

DEBUG 47225 ---      : !!!Session.FlushMode = ALWAYS
DEBUG 47225 ---      : !!!NewSession.FlushMode = AUTO

Upvotes: 10

Views: 16957

Answers (1)

Vlad Mihalcea
Vlad Mihalcea

Reputation: 153710

You need to add the following property:

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

Upvotes: 7

Related Questions