if ( idFromDB == null ) {
//not inserted yet so we need to add initial value to increment to have the right next value in the DB
//FIXME that means there is a small hole as when there was not value in the DB, we do add initial value in a non atomic way
BasicDBObject updateForInitial = new BasicDBObject();
this.addSubQuery( "$inc", updateForInitial, valueColumnName, request.getInitialValue() );
currentCollection.findAndModify( query, null, null, false, updateForInitial, false, true );
idFromDB = request.getInitialValue(); //first time we ask this value
}
else {
idFromDB = result.get( valueColumnName );
}