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!

– James McMahon Apr 24 '09 at 15:51 In my case I had to add @Transactional to the entry point of my class. Before I just had @Transactional on my method that did the persisting. Not sure if I completely understand what is going on there.

– James McMahon Apr 24 '09 at 18:32 Apparently @Transactional only works on public methods. – James McMahon Apr 27 '09 at 13:57 Thank you, you save my day! – Alexander Temerev May 14 '10 at 19:20.

Probably you're keeping the transaction active and it is not calling "commit" until other methods running supporting the active transaction end (all "voting" for commit and none for rollback. ) If you're sure that the entity you're going to persist is ok you could probably do this: @TransactionManagement(TransactionManagementType. BEAN) public class AccountManager implements IAccountManager { ..} and manage your entity persistance adding: @Resource private SessionContext sessionContext; public Account storeAccount(Account ac) { sessionContext.

GetUserTransaction().begin(); ac = em. Merge(ac); em. Persist(ac); sessionContext.

GetUserTransaction().commit(); return ac; }.

TransactionManagement is EJB. – James McMahon Apr 24 '09 at 15:20.

The records aren't necessarily committed for all users to see after the call to persist...

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

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

Probably you're keeping the transaction active and it is not calling "commit" until other methods running supporting the active transaction end (all "voting" for commit and none for rollback.).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions