You are currently browsing legacy 4.1 version of documentation. Click here to switch to the newest 5.1 version.
Session: Storing Entities
To store entities inside the session object, use one of the three
First overload: Stores the entity in a session, then extracts the ID from the entity or generates a new one if it's not available.
void store(Object entity);
Second overload: Stores the entity in a session with given ID.
void store(Object entity, String id);
Third overload: Stores the entity in a session with given ID, forces concurrency check with given change vector.
void store(Object entity, String changeVector, String id);
|entity||Object||Entity that will be stored|
|changeVector||String||Entity changeVector, used for concurrency checks (
|id||String||Entity will be stored under this ID, (
Employee employee = new Employee(); employee.setFirstName("John"); employee.setLastName("Doe"); // generate Id automatically session.store(employee); // send all pending operations to server, in this case only `Put` operation session.saveChanges();