EntityManager persist() not saving anything to database?

This generally happens when Transaction in not applied.. I doubt @Transactional interceptor is not intercepting properly.

Persist() means "add object to list of managed entries". To save object to data base you must call flush() method. But remember you must call in inside the transaction.

//Edit: Example save method. Public void save(T t){ // begin transaction em.getTransaction().begin(); if (!em. Contains(t)) { // persist object - add to entity manager em.

Persist(t); // flush em - save to DB em.flush(); } // commit transaction at all em.getTransaction().commit(); } This is not the best that You can make, but good enough.

2 flush() is called before a commit either way. – bestsss Mar 20 at 19:23 Added entityManager.flush() and got javax.persistence. TransactionRequiredException: no transaction is in progress – ivar Mar 20 at 19:38 Ivar look edition – KozioÅ‚ek Mar 20 at 20:09 one more.

JpaTemplate is just facade for javax.persistance.EntityManager. – KozioÅ‚ek Mar 20 at 20:14.

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