What does EntityManager.flush do and why do I need to use it? - madhusudana30/AlternativeJPAForWebSphere GitHub Wiki

https://stackoverflow.com/questions/17703312/what-does-entitymanager-flush-do-and-why-do-i-need-to-use-it A call to EntityManager.flush(); will force the data to be persist in the database immediately as EntityManager.persist() will not (depending on how the EntityManager is configured : FlushModeType (AUTO or COMMIT) by default it's set to AUTO and a flush will be done automatically by if it's set to COMMIT the persitence of the data to the underlying database will be delayed when the transaction is commited).