Session has the following save- and Value-related methods:
javax.jcr. |
|
void |
save() Validates all pending changes currently recorded in this Session. If validation of all pending changes succeeds, then this change information is cleared from the Session. If the save occurs outside a transaction, the changes are persisted and thus made visible to other Sessions. If the save occurs within a transaction, the changes are not persisted until the transaction is committed (see 8.1 Transactions for more details). If validation fails, then no pending changes are saved and they remain recorded on the Session. There is no best-effort or partial save. The item in persistent storage to which a transient item is saved is determined by matching UUIDs and paths. See 7.1.2 Saving by UUID and Path, for details. An AccessDeniedException will be thrown if any of the changes to be persisted would violate the access permissions of the Session. If any of the changes to be persisted would cause the removal of a node that is currently the target of a REFERENCE property then a ReferentialIntegrityException is thrown, provided that this Session has read access to that REFERENCE property. If, on the other hand, this Session does not have read access to the REFERENCE property in question, then an AccessDeniedException is thrown instead. An ItemExistsException will be thrown if any of the changes to be persisted would be prevented by the presence of an already existing item in the workspace. A ConstraintViolationException will be thrown if any of the changes to be persisted would violate a node type restriction. Additionally, a repository may use this exception to enforce implementation- or configuration-dependant restrictions. An InvalidItemStateException is thrown if any of the changes to be persisted conflicts with a change already persisted through another session and the implementation is such that this conflict can only be detected at save-time and therefore was not detected earlier, at change-time. A VersionException is thrown if the save would result in a change to persistent storage that would violate the read-only status of a checked-in node. A LockException is thrown if the save would result in a change to persistent storage that would violate a lock. A NoSuchNodeTypeException is thrown if the save would result in the addition of a node with an unrecognized node type. A RepositoryException will be thrown if another error occurs. |
void |
refresh(boolean keepChanges) If keepChanges is false, this method discards all pending changes currently recorded in this Session and returns all items to reflect the current saved state. Outside a transaction this state is simply the current state of persistent storage. Within a transaction, this state will reflect persistent storage as modified by changes that have been saved but not yet committed. If keepChanges is true then pending changes are not discarded but items that do not have changes pending have their state refreshed to reflect the current saved state, thus revealing changes made by other sessions. In some implementations this may be a null operation. See 7.1.3.4 Seeing Changes Made by Other Sessions, for more details. A RepositoryException is thrown if another error occurs. |
boolean |
hasPendingChanges() Returns true if this Session holds pending (that is, unsaved) changes; otherwise returns false. A RepositoryException is thrown if an error occurs. |
ValueFactory |
getValueFactory() This method returns a ValueFactory that is used to create Value objects for use when setting repository properties (see 7.1.5 Adding and Writing Properties and 7.1.5.3 Creating Value Objects). If writing to the repository is not supported (because this is a level 1-only implementation, for example) an UnsupportedRepositoryOperationException will be thrown. |