New to Hibernate here. Confused with the transaction...
Is there any difference b/w
begin a transaction, select, update
and select, begin transaction, update?
Code:
Session newSession = getSessionFactory().openSession();
Transaction newTransaction = newSession.beginTransaction();
SomeObject obj = newSession.load....
obj.setName("WHATEVER");
newSession.saveOrUpdate(obj);
newTransaction.commit();
newSession.close();
Code:
Session newSession = getSessionFactory().openSession();
SomeObject obj = newSession.load....
Transaction newTransaction = newSession.beginTransaction();
obj.setName("WHATEVER");
newSession.saveOrUpdate(obj);
newTransaction.commit();
newSession.close();
Thanks!