Language
C# Node.JS
Article For
3.0 3.5 4.0 4.1 4.2 5.0 5.2 5.3

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.

Syntax

<T> void refresh(T entity);
Parameters
entity T Instance of an entity that will be refreshed

Example

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());

Remarks

Refreshing a transient entity (not attached) or an entity that was deleted on server-side will result in a IllegalStateException.