Spring, Hibernate & JPA: Calling persist on entitymanager does not seem to commit to database Spring, Hibernate & JPA: Calling persist on entitymanager does not seem to commit to database spring spring

Spring, Hibernate & JPA: Calling persist on entitymanager does not seem to commit to database


Thanks to eric and Juan Manuel's answers, I was able to figure out that the transaction wasn't committed.

Adding @Transactional to the storeAccount method did the trick!


I actually came across another way that this can happen.

In an injected EntityManager, no updates will ever occur if you have persistence.xml specified like this:

<persistence-unit name="primary" transaction-type="RESOURCE_LOCAL">

You need to remove the transaction-type attribute and just use the default which is JTA.


You do not explicitly need to call the persist method. The merge operation would write the changes to the DB upon commit.