Objectbox-java: One of the fields can not be saved until extra field is added

Created on 28 Feb 2017  路  11Comments  路  Source: objectbox/objectbox-java

I have a POJO class that looks like this:

        private String name;
    private String packageName;
    private String category;
    @Transient
    private Drawable icon;
    private boolean permission;
    @Id
    private long id;

    private AppInfo(String packageName) {
        this.packageName = packageName;
        setPermission(true);
    }

Whenever i put the object of this class to objectbox, category field is not being saved and is always null if I query objectbox after saving. But if I add any extra field to the class and try to save it, this field can not be saved and category can. So is it bug or I am doing smth wrong?

bug

All 11 comments

You are on version 0.9.8?

Yes, I am on 0.9.8.

Can you post your objectbox-models/default.json file? Or send it to [email protected] with greenrobot as replacement.

{
  "_note1": "KEEP THIS FILE! Check it into a version control system (VCS) like git.",
  "_note2": "ObjectBox manages crucial IDs for your object model. See docs for details.",
  "_note3": "If you have VCS merge conflicts, you must resolve them according to ObjectBox docs.",
  "entities": [
    {
      "id": "1:3349757779937833927",
      "lastPropertyId": "10:2163551839097331748",
      "name": "AppInfo",
      "properties": [
        {
          "id": "1:1090055733345112569",
          "name": "name"
        },
        {
          "id": "2:750877309369470237",
          "name": "packageName"
        },
        {
          "id": "4:5300652845611614704",
          "name": "permission"
        },
        {
          "id": "6:883617828156339054",
          "name": "category"
        },
        {
          "id": "7:4971676533519676902",
          "name": "id"
        },
        {
          "id": "9:2381424945396777257",
          "name": "BUG_FIELD"
        },
        {
          "id": "10:2163551839097331748",
          "name": "icon"
        }
      ]
    }
  ],
  "lastEntityId": "1:3349757779937833927",
  "lastIndexId": "2:6635700790649304596",
  "lastSequenceId": "0:0",
  "modelVersion": 2,
  "retiredEntityUids": [],
  "retiredIndexUids": [
    2190533411163836588,
    6635700790649304596
  ],
  "retiredPropertyUids": [
    5867614080764540892,
    6859232596269123437,
    8173624162316961627
  ],
  "version": 1
}

Here is the json file. Seems like category field is there but still i can not save it if there is no extra field BUG_FIELD. Also when i added another filed icon of type byte[] it also becomes unsaveable.

Will investigate. To keep you productive, try either:

  • delete your database on the device (e.g. just clear app data)
  • or, delete the objectbox-models/default.json file and let ObjectBox re-generate it.

Let me know if that worked for you.

Unfortunately, none of this made it work. Any other suggestions?

Problem identified. Expect a fix soon.

Please test with 'io.objectbox:objectbox-android:0.9.9-SNAPSHOT' (no update for gradle plugin required/available). Ensure to put() the data again with the new version before getting it.

Thank you, as soon as I try I will tell you the results. Also regarding this issue it seems that everytime i change fields in the pojo object and try to save again, some or even all fields stop saving. It is only possible to fix the issue after uninstalling an app and removing the generated json file.

So far no issues, hope it stays this way :)

0.9.9 released

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chiara-jm picture chiara-jm  路  17Comments

greenrobot picture greenrobot  路  56Comments

greenrobot picture greenrobot  路  27Comments

DJafari picture DJafari  路  29Comments

Gaket picture Gaket  路  79Comments