I have three layers i.e Action,Service,DAO layers. I have loaded an object(of Employee class) from DB using hibernate with id 123.I have done some modifications to employee object.Later, I have create hibernate business object and done some modifications to that.
Employee e = service.getEmp(123);
e.setName("Ashok");
Order o = new Order
o.setNumber(567);
service.saveOrUpdate(o);
In this scenario, why it is trying to update employee object even though I not saying to save it? How to detach that from session?I don’t want hibernate to update employee object.
I quote from the hibernate docs:
And
Mark collections with
cascade="evict". Then Session.evict(Object) the object before flushing on your object (if you haveFlushMode.AUTOthen maybe set it toMANUALuntil you have done what you want).