BackendlessException: InvalidSchemaException: Unable to retrieve data - unknown entity.

I’m trying to save a java obect (of type ListTheme) to Backendless in an Android project using the following synchronous call (This line of code is running in a background thread):
response = Backendless.Data.of( ListTheme.class ).save( listTheme );The ListTheme object contains fields made up of String, int, long, float, and boolean data types.I’m receive the following BackendlessException:BackendlessException: Code: Server.Processing; Message: java.lang.RuntimeException: com.backendless.exceptions.persistence.InvalidSchemaException: Unable to retrieve data - unknown entity.

Question: What might be causing this error? And Where can i find documentation on Backendless exceptions that might give me an idea of what causes errors?

Could you try it again? We had a brief outage with the database, I’d like to rule that out from possible causes.

Mark

Mark … Just re-ran my app. I’m still getting the “unknown entity” error. It’s probably best if you download and run my Android app from github. https://github.com/LorenBaker/A1List_Clean

When you start the app … register a new user… then open logcat and you should see error messages.

The errors occurs on line 112 in the class com.lbconsulting.a1list.domain.repository.ListThemeRepository_Impl.

Thanks again for your help.

Loren,

As much as I’d like to, this approach does not scale - we really cannot run complete apps of our users. If you can put together a smaller sample demonstrating the problem, it would work much better and we’d be happy to look into it.

Hope you understand.

Regards,
Mark

Hmmm… I’ve just started this app and the only thing that it does is add several “ListTheme” objects upon a new user registration. The only thing i would strip out is the ContentProvider and related SQLite data table that store the same “ListTheme” objects locally. (Which is working).

So I’m not sure how to proceed?

Create a super simple console java program where you run the query in question and see if it works there:

public class Test
{
public static void main( String[] args )
{
Backendless.initApp( appId, secretKey, version );
// add your code here
}
}

My guess is that i’m doing something obviously wrong. But i receive the following error:

BackendlessException{ code: ‘Server.Processing’, message: ‘java.lang.RuntimeException: com.backendless.exceptions.persistence.InvalidSchemaException: Unable to retrieve data - unknown entity’ }

Here’s my simple test code.

import com.backendless.Backendless;
import com.backendless.exceptions.BackendlessException;

import java.util.List;

/**

  • Created by Loren on 2/19/2016.
    */
    public class Test

{

public static void main(String[] args)

{
    Backendless.initApp("E3C25B04-0237-343F-FF8D-4ACDD2199C00", "A3F008D8-0966-48BC-FFEA-3DF898407400", "v1");
    createListThemes();

// add your code here

}

private static void createListThemes() {

    int[] colors = {
            0x39add1, // light blue
            0x3079ab, // dark blue
            0xc25975 // mauve
    };


    try {
        // create initial ListThemes
        ListTheme newListTheme;

        newListTheme = ListTheme.newInstance("Genoa",
                colors[0], colors[0], colors[0],
                17f, 10f, 10f, false, false, true);
        ListTheme response = Backendless.Data.of(ListTheme.class).save(newListTheme);
    } catch (BackendlessException e) {
        e.printStackTrace();
    }

}

}
And my ListTheme class:

import java.text.DateFormat;
import java.util.Date;
import java.util.UUID;

/**

  • Java object for an A1List Theme.
    */

public class ListTheme {

private String objectId;
private long Id;
private String name;
private int startColor; // int
private int endColor;
private int textColor; // int
private float textSize; //float
private float horizontalPaddingInDp; //float dp. Need to convert to float px
private float verticalPaddingInDp; //float dp. Need to convert to float px
private boolean themeDirty;
private boolean bold;
private boolean checked;
private boolean defaultTheme;
private boolean markedForDeletion;
private boolean transparent;
private String uuid;
private Date updated;
private Date created;


public ListTheme() {
    // A default constructor is required.
}

//region Getters and Setters

public static ListTheme newInstance(String newThemeName,
                                    int startColor, int endColor,
                                    int textColor, float textSize,
                                    float horizontalPaddingInDp, float verticalPaddingInDp,
                                    boolean isBold, boolean isTransparent, boolean isDefaultTheme) {

    ListTheme newTheme = new ListTheme();
    newTheme.setName(newThemeName);
    newTheme.setStartColor(startColor);
    newTheme.setEndColor(endColor);
    newTheme.setTextColor(textColor);
    newTheme.setTextSize(textSize);
    newTheme.setHorizontalPaddingInDp(horizontalPaddingInDp);
    newTheme.setVerticalPaddingInDp(verticalPaddingInDp);
    newTheme.setBold(isBold);
    newTheme.setChecked(false);
    newTheme.setDefaultTheme(isDefaultTheme);
    newTheme.setMarkedForDeletion(false);
    newTheme.setTransparent(isTransparent);
    String newUuid = UUID.randomUUID().toString();
    // replace uuid "-" with "_" to distinguish it from Backendless objectId
    newUuid = newUuid.replace("-", "_");
    newTheme.setUuid(newUuid);

    return newTheme;
}

public int getEndColor() {
    return endColor;
}

public void setEndColor(int endColor) {
    setThemeDirty(true);
    this.endColor = endColor;
}

public float getHorizontalPaddingInDp() {
    return horizontalPaddingInDp;
}

public void setHorizontalPaddingInDp(float horizontalPaddingInDp) {
    setThemeDirty(true);
    this.horizontalPaddingInDp = horizontalPaddingInDp;
}

public float getVerticalPaddingInDp() {
    return verticalPaddingInDp;
}

public void setVerticalPaddingInDp(float verticalPaddingInDp) {
    setThemeDirty(true);
    this.verticalPaddingInDp = verticalPaddingInDp;
}

public boolean isThemeDirty() {
    return themeDirty;
}

public void setThemeDirty(boolean themeDirty) {
    this.themeDirty = themeDirty;
}

public boolean isBold() {
    return bold;
}

public void setBold(boolean isBold) {
    setThemeDirty(true);
    this.bold = isBold;
}

public boolean isChecked() {
    return checked;
}

public void setChecked(boolean isChecked) {
    setThemeDirty(true);
    this.checked = isChecked;
}

public boolean isDefaultTheme() {
    return defaultTheme;
}

public void setDefaultTheme(boolean isDefaultTheme) {
    setThemeDirty(true);
    this.defaultTheme = isDefaultTheme;
}

public boolean isMarkedForDeletion() {
    return markedForDeletion;
}

public void setMarkedForDeletion(boolean isMarkedForDeletion) {
    setThemeDirty(true);
    this.markedForDeletion = isMarkedForDeletion;
}

public boolean isTransparent() {
    return transparent;
}

public void setTransparent(boolean isTransparent) {
    setThemeDirty(true);
    this.transparent = isTransparent;
}

public String getName() {
    return name;
}

public void setName(String name) {
    setThemeDirty(true);
    this.name = name;
}

public String getObjectId() {
    if (objectId == null || objectId.isEmpty()) {
        objectId = "N/A";
    }

    return objectId;
}

public void setObjectId(String objectId) {
    this.objectId = objectId;
}

public long getId() {
    return Id;
}

public void setId(long id) {
    Id = id;
}

public int getStartColor() {
    return startColor;
}

public void setStartColor(int startColor) {
    setThemeDirty(true);
    this.startColor = startColor;
}

public int getTextColor() {
    return textColor;
}

public void setTextColor(int textColor) {
    setThemeDirty(true);
    this.textColor = textColor;
}

public float getTextSize() {
    return textSize;
}

public void setTextSize(float textSize) {
    setThemeDirty(true);
    this.textSize = textSize;
}

public String getUuid() {
    return uuid;
}

public void setUuid(String uuid) {
    setThemeDirty(true);
    this.uuid = uuid;
}

public Date getUpdated() {
    return updated;
}

public void setUpdated(Date updated) {
    this.updated = updated;
}

public Date getCreated() {
    return created;
}

public void setCreated(Date created) {
    this.created = created;
}


//endregion

@Override
public String toString() {
    return getName();

}

}

Hi Loren,

I was able to run this code after making the following change. I had to comment out the code in the getObjectId() method in the ListTheme.java class:

  public String getObjectId()
  {
     /*
    if( objectId == null || objectId.isEmpty() )
    {


      objectId = "N/A";


    }   */


    return objectId;
  }

The reason that code cannot be there is because when you save a new instance of ListTheme, the objectId property must not be initialized. When you set it to “N/A” (or any other value for that matter) and save a new object, it tells Backendless that the object is not “new” per-se and as a result, Backendless will try to persist the object using the objectId value.

Hope this helps.

Mark

Thanks Mark … That fixed my problem. Should have figured that out myself.

Thanks for you help.