Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 486
PaintedRed Avatar asked May 13 '15 09:05

PaintedRed


1 Answers

You need to add the following property:

spring.jpa.properties.org.hibernate.flushMode=ALWAYS
like image 176
Vlad Mihalcea Avatar answered Oct 15 '22 02:10

Vlad Mihalcea