I'm using Hibernate with Spring framework, and running into an Opportunistic Locking, so I have a fundamental question:
Does Hibernate consider the object "changed/dirty" as soon as its setter is called, for example: theEmployee.setAge(32)
so even if age
had already been 32
, it will be considered "changed", or would Hibernate figure out that even though the setter was called, the object, effectively, has not been changed?
In other words, if I want to prevent unnecessary write's, is it necessary to code:
if (theEmployee.getAge() != age) { theEmployee.setAge(age); }
...or it is sufficient to code: theEmployee.setAge(age);