You are currently browsing legacy 3.0 version of documentation. Click here to switch to the newest 5.0 version.
Session: How to mark entity as readonly?
Entities can be marked as read-only using
markReadOnly. This operation is equal to adding to entity metadata a key
Raven-Read-Only with value set to
Implications of setting entity as read-only are as follows:
- change tracking won't apply to such entity
- forcing updates or deletes (e.g. using
Commands) will throw
public void markReadOnly(Object entity);
|entity||Object||Instance of an entity that will be marked as read-only.|
Employee employee = session.load(Employee.class, "employees/1"); session.advanced().markReadOnly(employee); session.saveChanges();