You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.0 version.
Session: How to get entity etag?
When document is downloaded from server it contains various metadata information e.g. Id or current etag. Current etag is stored within metadata in session and available for each entity using
getEtagFor method from
advanced session operations.
public <T> Etag getEtagFor(T instance);
|instance||T||Instance of an entity for which etag will be returned.|
|ETag||Returns current etag for an entity. If the
Employee employee = session.load(Employee.class, "employees/1"); Etag etag = session.advanced().getEtagFor(employee);