4.1.3.2 Transient Storage in the Session

Notice the use of the method Session.save in the above examples. This method is needed because changes made through most methods of Session, Node3 or Property are not immediately reflected in the persistent workspace. The changes are held in transient storage associated with the Session object until they are either persisted (using Session.save or Item.save) or discarded (using Session.refresh(false) or Item.refresh(false)).

Changes not yet saved or discarded are called pending changes. Pending changes are immediately visible through the session that made them but are not visible through other sessions accessing the same workspace.

Session.save validates and, if validation succeeds, persists all pending changes currently stored in the Session object, making them visible to other sessions (though this only applies if the save is not within the scope of a transaction, see 4.1.3.3 Transactions, below). Conversely, Session.refresh(false) discards all pending changes currently stored in the Session.

For more fine-grained control over which changes are persisted or discarded, the methods Item.save and Item.refresh are also provided. Item.save saves all pending changes in the Session that apply to that particular item or its subtree. Analogously, Item.refresh(false) discards all pending changes that apply to that item or its subtree. See 7.1 Writing Repository Content.