How to Check for Entity Changes
To check if a specific entity differs from the one downloaded from server, the hasChanged
method from the advanced
session operations can be used.
Syntax
boolean hasChanged(Object entity)
Parameters |
|
|
entity |
Objec |
Instance of entity for which changes will be checked. |
Return Value |
|
boolean |
Indicated if given entity has changed. |
Example
Employee employee = session.load(Employee.class, "employees/1-A");
boolean hasChanged = session.advanced().hasChanged(employee);// false
employee.setLastName("Shmoe");
hasChanged = session.advanced().hasChanged(employee);// true