Error in relational Table

i have this error when i try to save an relational object

this is my code
TableInventory item = new TableInventory();
item.setItemCode(Codigo.getText().toString());
item.setDescription(Descripcion.getText().toString());
item.setCategoryId(adapter.getItem(_position));
item.setQuantityWarehouse(Double.parseDouble(CantidadBodega.getText().toString()));
item.setQuantityOffice(Double.parseDouble(CantidadRestaurante.getText().toString()));
item.setTotalQuantity(Double.parseDouble(CantidadBodega.getText().toString()) + Integer.parseInt(CantidadRestaurante.getText().toString()));
item.setUnitPrice(Double.parseDouble(PrecioUnitario.getText().toString()));
item.setTaxId(adapterImpuesto.getItem(_positionImpuesto));

item.setImage(URL);

item.setMinimunQuantity(Double.parseDouble(CantidadMinima.getText().toString()));
item.setColor(color);

Backendless.Persistence.of(TableInventory.class).save(item, new AsyncCallback<TableInventory>() {
@Override
public void handleResponse(TableInventory tableInventory) {

    AlertDialog.Builder dialog = new AlertDialog.Builder(CreateItemActivity.this);
    dialog.setTitle("Datos Guardados");
    dialog.setMessage("Los Datos se Guardaron Correctamente");
    dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent();
            setResult(2, intent);
            finish();
        }
    });

    AlertDialog alertDialog = dialog.create();
    alertDialog.show();

}

@Override
public void handleFault(BackendlessFault backendlessFault) {
    Toast msg = Toast.makeText(CreateItemActivity.this, backendlessFault.getMessage(), Toast.LENGTH_SHORT);
    msg.show();
}

});

and this is my error:03-11 12:28:58.974 27612-27612/casacatracha.com.casacatracha E/AndroidRuntime: FATAL EXCEPTION: main
Process: casacatracha.com.casacatracha, PID: 27612
BackendlessException{ code: ‘IllegalArgumentException’, message: ‘categoryId’ }
at com.backendless.FootprintsManager$Inner.duplicateFootprintForObject(FootprintsManager.java:205)
at com.backendless.Persistence$3.handleResponse(Persistence.java:162)
at com.backendless.async.message.AsyncMessage$ResponseHandler.handle(AsyncMessage.java:64)
at com.backendless.async.message.AsyncMessage.handleCallback(AsyncMessage.java:41)
at com.backendless.core.AndroidCarrier$1.handleMessage(AndroidCarrier.java:37)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.NoSuchFieldException: categoryId
at java.lang.Class.getDeclaredField(Class.java:886)
at com.backendless.utils.ReflectionUtil.getField(ReflectionUtil.java:65)
at com.backendless.utils.ReflectionUtil.getField(ReflectionUtil.java:71)
at com.backendless.utils.ReflectionUtil.getFieldValue(ReflectionUtil.java:39)
at com.backendless.FootprintsManager$Inner.duplicateFootprintForObject(FootprintsManager.java:161)
at com.backendless.Persistence$3.handleResponse(Persistence.java:162)
at com.backendless.async.message.AsyncMessage$ResponseHandler.handle(AsyncMessage.java:64)
at com.backendless.async.message.AsyncMessage.handleCallback(AsyncMessage.java:41)
at com.backendless.core.AndroidCarrier$1.handleMessage(AndroidCarrier.java:37)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Hi Franklin,

I do not know what the data type for “categoryId” is on the server (check the type in your table using backendless console), but it looks like the following call sets it to an object:

item.setCategoryId(adapter.getItem(_position));

I suspect it should be a primitive value (or a String).

Regards,
Mark

well the field CategoryId it’s a relational field one to one from inventryTable to CagoriesTable, and the line item.setCategoryId(adapter.getItem(_position)); gets the CategorieTable object from a custom adapter of CateogiesTable, but you know what my program show this error but when i go to see my data the object is saved, i dont know why i get this error.

Could you please attach your TableInventory source? And also a screenshot of the TableInventory table schema.

Regards,
Mark

look this is my code and Schema, please advise me if i have an error. i tried to save another item in my tableinventory and i got the same error but in my data is saved.

TableTaxes.txt (837B)

TableCategories.txt (477B)

TableInventory.txt (2.65kB)

Franklin,

Per the JavaBean convention the following getter/setter methods identify property “categoryId”:

    public TableCategories getCategoryId()
    {
        return this.CategoryId;
    }


    public void setCategoryId(TableCategories CategoryId)
    {
        this.CategoryId = CategoryId;
    }

However, in your schema the column name is “CategoryId” (starting with an upper case letter). As a result, there is a mismatch between the code and schema. You can fix this by either renaming the column in the table or mapping the property in the code to the column name as it exists on the server. For the latter, you do the following:

 @MapToProperty( property="categoryId")  
public TableCategories getCategoryId()
    {
        return this.CategoryId;
    }

The MapToProperty annotation is defined in the “weborb.service” package.

Regards,
Mark