1
  • entityManager.setFlushMode(FlushModeType.AUTO)
  • entityManager.setFlushMode(FlushModeType.COMMIT)

What is the difference between above two and what is the advantage of using COMMIT flushMode?

Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142
Wolverine789
  • 407
  • 2
  • 6
  • 10

1 Answers1

0

JPA AUTO causes a flush to the database before a query is executed. Simple operations like find don't require a flush since the library can handle the search, however queries would be much more complicated, and so if AUTO is set, it will flush it first. If the mode is set to COMMIT, it will only flush the changes to the database upon a call to commit or flush. If COMMIT is set, and a query is run, it will not return results that have not been flushed.

Source: Another stack overflow question

Community
  • 1
  • 1
Michael W
  • 3,515
  • 8
  • 39
  • 62