return new Tuple( new CouchDBTupleSnapshot( key ) );
}
@Override
public void updateTuple(Tuple tuple, EntityKey key, TupleContext tupleContext) {
CouchDBTupleSnapshot snapshot = (CouchDBTupleSnapshot) tuple.getSnapshot();
String revision = (String) snapshot.get( Document.REVISION_FIELD_NAME );
// load the latest revision for updates without the revision being present; a warning about
// this mapping will have been issued at factory start-up
if ( revision == null && !snapshot.isCreatedOnInsert() ) {
revision = getDataStore().getCurrentRevision( Identifier.createEntityId( key ), false );
}
// this will raise an optimistic locking exception if the revision is either null or not the current one
getDataStore().saveDocument( new EntityDocument( key, revision, tuple ) );