Reputation: 23
Can I use transaction like below:
persistentObj.setValue("xyz");
session.beginTransaction().commit();
assuming session is created before fetching object from database?
Upvotes: 2
Views: 331
Reputation: 659
As you write above, only the object is changed. It will not be persisted to the database.
You must call persist()
or saveOrUpdate()
method to make changes to object. You should also follow this order: begin transaction, update or save, and then commit.
Upvotes: 1