You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 5.1 version.
Session: How to Refresh an Entity
To update an entity with the latest changes from the server, use the
refresh method from
advanced session operations.
<T> void refresh(T entity);
|entity||T||Instance of an entity that will be refreshed|
Employee employee = session.load(Employee.class, "employees/1"); Assert.assertEquals("Doe", employee.getLastName()); // LastName changed to 'Shmoe' session.advanced().refresh(employee); Assert.assertEquals("Shmoe", employee.getLastName());
Refreshing a transient entity (not attached) or an entity that was deleted on server-side will result in a