public ObjectResult addObject(String tableName, DBObject dbObj) {
        Utils.require(!Utils.isEmpty(tableName), "tableName");
        Utils.require(dbObj != null, "dbObj");
        TableDefinition tableDef = m_appDef.getTableDef(tableName);
        Utils.require(tableDef != null,
                      "Unknown table for application '%s': %s", m_appDef.getAppName(), tableName);
        
        try {
            // Send single-object batch to "POST /{application}/{table}"
            DBObjectBatch dbObjBatch = new DBObjectBatch();
            dbObjBatch.addObject(dbObj);
            byte[] body = Utils.toBytes(dbObjBatch.toDoc().toJSON());
            StringBuilder uri = new StringBuilder(Utils.isEmpty(m_restClient.getApiPrefix()) ? "" : "/" + m_restClient.getApiPrefix());
            uri.append("/");
            uri.append(Utils.urlEncode(m_appDef.getAppName()));
            uri.append("/");
            uri.append(Utils.urlEncode(tableName));
            RESTResponse response = 
                m_restClient.sendRequest(HttpMethod.POST, uri.toString(), ContentType.APPLICATION_JSON, body);
            m_logger.debug("addBatch() response: {}", response.toString());
            BatchResult batchResult = createBatchResult(response, dbObjBatch);
            
            ObjectResult objResult = null;
            if (batchResult.isFailed()) {
                objResult = ObjectResult.newErrorResult(batchResult.getErrorMessage(), dbObj.getObjectID());
            } else {
                objResult = batchResult.getResultObjects().iterator().next();
                if (Utils.isEmpty(dbObj.getObjectID())) {
                    dbObj.setObjectID(objResult.getObjectID());
                }
            }
            return objResult;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
public ObjectResult addObject ( String tableName , DBObject dbObj ) { Utils . require ( ! Utils . isEmpty ( tableName ) , "tableName" ) ; Utils . require ( dbObj != null , "dbObj" ) ; TableDefinition tableDef = m_appDef . getTableDef ( tableName ) ; Utils . require ( tableDef != null , "Unknown table for application '%s': %s" , m_appDef . getAppName ( ) , tableName ) ; try { DBObjectBatch dbObjBatch = new DBObjectBatch ( ) ; dbObjBatch . addObject ( dbObj ) ; byte [ ] body = Utils . toBytes ( dbObjBatch . toDoc ( ) . toJSON ( ) ) ; StringBuilder uri = new StringBuilder ( Utils . isEmpty ( m_restClient . getApiPrefix ( ) ) ? "" : "/" + m_restClient . getApiPrefix ( ) ) ; uri . append ( "/" ) ; uri . append ( Utils . urlEncode ( m_appDef . getAppName ( ) ) ) ; uri . append ( "/" ) ; uri . append ( Utils . urlEncode ( tableName ) ) ; RESTResponse response = m_restClient . sendRequest ( HttpMethod . POST , uri . toString ( ) , ContentType . APPLICATION_JSON , body ) ; m_logger . debug ( "addBatch() response: {}" , response . toString ( ) ) ; BatchResult batchResult = createBatchResult ( response , dbObjBatch ) ; ObjectResult objResult = null ; if ( batchResult . isFailed ( ) ) { objResult = ObjectResult . newErrorResult ( batchResult . getErrorMessage ( ) , dbObj . getObjectID ( ) ) ; } else { objResult = batchResult . getResultObjects ( ) . iterator ( ) . next ( ) ; if ( Utils . isEmpty ( dbObj . getObjectID ( ) ) ) { dbObj . setObjectID ( objResult . getObjectID ( ) ) ; } } return objResult ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } }
Add the given object to the given table, which must be defined for a table that
belongs to this session's application. This is a convenience method that bundles
the DBObject in a {@link DBObjectBatch} and calls
{@link #addBatch(String, DBObjectBatch)}. The {@link ObjectResult} from the batch
result is returned.

@param tableName Name of table to add object to.
@param dbObj     {@link DBObject} of object to add to the database.
@return          {@link ObjectResult} of the add request. The result can be used to
determine the ID of the object if it was added by the system.