You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 4.2 version.

We can help you with migration to the latest RavenDB

Contact Us Now
see on GitHub

Session: How to Clear a Session

To clear session state, to stop tracking entities and remove all pending commands, etc. the clear method is used from the advanced session operations.

Syntax

void clear()

Example

Employee employee = new Employee();
employee.setFirstName("John");
employee.setLastName("Doe");
session.store(employee);

session.advanced().clear();

session.saveChanges(); // nothing will hapen