java - JPA commit() after persist() : Required or Not -


i working jpa 2.0 project, saving entity class objects :-

    initialcontext ctx = new initialcontext();     usertransaction usertrans = (usertransaction)      ctx.lookup("java:comp/usertransaction");     entitymanagerfactory emf = persistence.createentitymanagerfactory(persistence_name);     entitymanager em = emf.createentitymanager();     user user = new user("ankit","nigam",25);     em.persist(user); // persisted in db after executes     usertrans.commit(); // whether required or not. 

so whether using usertrans.commit() or not, user object getting saved in db, after persist() executes. of colleagues say, standard should commit() transaction.

what should approach follow , whats logic behind commit() , persist(). please throw lights.

is autocommit on in db? if reason why changes permanently stored in db irrespective of whether or not commit transaction application. in production autocommit set off because hampers performance/response time of db, why developers encouraged control commit or rollback of transaction application. link details command handle autocommit in db2: http://www.db2util.com/administration/options-db2-command-line-disable-autocommit/


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -