Reputation: 387
I'm using the EntityManager to persist data into my database.
public void save(X x){
entityManager.persist(x);
entityManager.flush();
triggerDataChange();
}
After flushing the data I call the triggerDataChange() Method to send a message to an external component which depends on the newly written data.
Question: Can I rely on the flush method returning after the data has been written to database successfully?
Thanks for your help.
Upvotes: 1
Views: 741
Reputation: 19185
Your transaction is same so even if the transaction rolls back it rolls back completely. Flush will not commit the transaction as it can be still rolled back. So In your implementation whatever you are doing is fine.
Upvotes: 1