question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DB's last entity ID 5 is higher than 4 from model

See original GitHub issue

when I install a newer version of my app over an old release version caused this Exception ,how to solve it?

I once deleted the files in the folder objectbox-models and rebuild them when coding the new version. Is this the cause?

java.lang.RuntimeException: Unable to instantiate application com.taoche.qctt.app.App: io.objectbox.exception.DbException: DB's last entity ID 5 is higher than 4 from model
	at android.app.LoadedApk.makeApplication(LoadedApk.java:565)
	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4519)
	at android.app.ActivityThread.access$1600(ActivityThread.java:147)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1346)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:135)
	at android.app.ActivityThread.main(ActivityThread.java:5254)
	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:910)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:705)
Caused by: io.objectbox.exception.DbException: DB's last entity ID 5 is higher than 4 from model
	at io.objectbox.BoxStore.nativeCreate(Native Method)
	at io.objectbox.BoxStore.<init>(BoxStore.java:197)
	at io.objectbox.BoxStoreBuilder.build(BoxStoreBuilder.java:308)
	at com.taoche.qctt.app.App.attachBaseContext(App.java:57)
	at android.app.Application.attach(Application.java:185)
	at android.app.Instrumentation.newApplication(Instrumentation.java:995)
	at android.app.Instrumentation.newApplication(Instrumentation.java:979)
	at android.app.LoadedApk.makeApplication(LoadedApk.java:560)
	... 10 more

old default.json

{
  "_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:1952766103365863709",
      "lastPropertyId": "5:8534718537150799611",
      "name": "NewsReadEntity",
      "properties": [
        {
          "id": "1:4454213282712056488",
          "name": "id"
        },
        {
          "id": "4:4995671780322277960",
          "indexId": "3:1701554255184595914",
          "name": "saveTime"
        },
        {
          "id": "5:8534718537150799611",
          "name": "newsId"
        }
      ],
      "relations": []
    },
    {
      "id": "2:4681455186000581093",
      "lastPropertyId": "5:1878320121943278157",
      "name": "SearchHistoryEntity",
      "properties": [
        {
          "id": "1:2509681780674567262",
          "name": "id"
        },
        {
          "id": "3:4144773757208887841",
          "name": "type"
        },
        {
          "id": "4:1796059445680556055",
          "name": "content"
        },
        {
          "id": "5:1878320121943278157",
          "indexId": "4:7238548514032321082",
          "name": "saveTime"
        }
      ],
      "relations": []
    },
    {
      "id": "4:3560015495734375645",
      "lastPropertyId": "10:61457877014357435",
      "name": "UserInfoEntity",
      "properties": [
        {
          "id": "1:602973440470861549",
          "name": "userId"
        },
        {
          "id": "2:3246723179484410592",
          "name": "userName"
        },
        {
          "id": "3:4293227510605898252",
          "name": "avatar"
        },
        {
          "id": "4:3515152886667629792",
          "name": "profile"
        },
        {
          "id": "5:5567729676601844469",
          "name": "grade"
        },
        {
          "id": "6:1228345978650353268",
          "name": "livePermission"
        },
        {
          "id": "7:3329156168540452629",
          "name": "isEditor"
        },
        {
          "id": "8:7163292701191435143",
          "name": "hasSign"
        },
        {
          "id": "10:61457877014357435",
          "name": "id"
        }
      ],
      "relations": []
    },
    {
      "id": "5:3024685112334106772",
      "lastPropertyId": "3:8308424872576718774",
      "name": "VideoHistoryEntity",
      "properties": [
        {
          "id": "1:2617505269500745415",
          "name": "id"
        },
        {
          "id": "2:6785869119173123775",
          "indexId": "5:1880192976898178181",
          "name": "saveTime"
        },
        {
          "id": "3:8308424872576718774",
          "name": "newsId"
        }
      ],
      "relations": []
    }
  ],
  "lastEntityId": "5:3024685112334106772",
  "lastIndexId": "5:1880192976898178181",
  "lastRelationId": "0:0",
  "lastSequenceId": "0:0",
  "modelVersion": 4,
  "modelVersionParserMinimum": 4,
  "retiredEntityUids": [
    2176690214929686409
  ],
  "retiredIndexUids": [
    5712274539482648998,
    2649951790214073402
  ],
  "retiredPropertyUids": [
    4605692285024303790,
    397063222858956460,
    926282552069903016,
    4571064178529368696,
    8717211572541988533,
    1283673548410501397,
    8633068216894386619,
    1837391302522505772,
    8625297986036545488,
    8049703795930077205
  ],
  "retiredRelationUids": [],
  "version": 1
}

new default.json

{
  "_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:7268819421552606349",
      "lastPropertyId": "3:6939051831393356699",
      "name": "NewsReadEntity",
      "properties": [
        {
          "id": "1:1265655690987026639",
          "name": "id"
        },
        {
          "id": "2:3748868742107361312",
          "indexId": "1:992960471105957472",
          "name": "saveTime"
        },
        {
          "id": "3:6939051831393356699",
          "name": "newsId"
        }
      ],
      "relations": []
    },
    {
      "id": "2:589186565352160929",
      "lastPropertyId": "4:2574504725553098708",
      "name": "SearchHistoryEntity",
      "properties": [
        {
          "id": "1:7394507230736567604",
          "name": "id"
        },
        {
          "id": "2:4011440010662506653",
          "indexId": "2:5189269226120590970",
          "name": "saveTime"
        },
        {
          "id": "3:3710097363655897871",
          "name": "type"
        },
        {
          "id": "4:2574504725553098708",
          "name": "content"
        }
      ],
      "relations": []
    },
    {
      "id": "3:3341669883490510788",
      "lastPropertyId": "13:5701479747961985769",
      "name": "UserInfoEntity",
      "properties": [
        {
          "id": "1:6109940089247558511",
          "name": "id"
        },
        {
          "id": "2:1619251787468389600",
          "name": "userId"
        },
        {
          "id": "3:3145953919205188275",
          "name": "userName"
        },
        {
          "id": "4:7487945478244672905",
          "name": "avatar"
        },
        {
          "id": "5:6775580645504193763",
          "name": "profile"
        },
        {
          "id": "6:7577744986006211462",
          "name": "grade"
        },
        {
          "id": "7:7104882922991678825",
          "name": "livePermission"
        },
        {
          "id": "8:8249101017412193529",
          "name": "isEditor"
        },
        {
          "id": "9:6005646416433093387",
          "name": "isBanned"
        },
        {
          "id": "10:2205641484297255349",
          "name": "bannedMsg"
        },
        {
          "id": "11:4630277244590003009",
          "name": "hasSign"
        },
        {
          "id": "12:5065561494695866755",
          "name": "sysMsgNum"
        },
        {
          "id": "13:5701479747961985769",
          "name": "nameLength"
        }
      ],
      "relations": []
    },
    {
      "id": "4:7190768811120423132",
      "lastPropertyId": "3:8438774495542963149",
      "name": "VideoHistoryEntity",
      "properties": [
        {
          "id": "1:4412742502218631092",
          "name": "id"
        },
        {
          "id": "2:6998696281007344674",
          "indexId": "3:4444069384638686879",
          "name": "saveTime"
        },
        {
          "id": "3:8438774495542963149",
          "name": "newsId"
        }
      ],
      "relations": []
    }
  ],
  "lastEntityId": "4:7190768811120423132",
  "lastIndexId": "3:4444069384638686879",
  "lastRelationId": "0:0",
  "lastSequenceId": "0:0",
  "modelVersion": 4,
  "modelVersionParserMinimum": 4,
  "retiredEntityUids": [],
  "retiredIndexUids": [],
  "retiredPropertyUids": [],
  "retiredRelationUids": [],
  "version": 1
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
PengXianglin2017commented, Sep 15, 2018

Use old default.json

1reaction
greenrobot-teamcommented, Feb 5, 2018

If you delete and re-generate the model file you have to delete the database (for example by uninstalling the app). Otherwise ObjectBox has no idea how to map existing data to the new model.

You can read more about how the ObjectBox model works. -ut

Read more comments on GitHub >

github_iconTop Results From Across the Web

DB's last entity ID 17 is higher than 15 from model
DB's last entity ID 17 is higher than 15 from model,Rebuilding the JSON file after deleting it does not work · Ask Question....
Read more >
Meta Model, IDs, and UIDs - ObjectBox Docs
Unlike relational databases like SQLite, ObjectBox does not require you to create a database schema. ... DB's last entity ID 4 is higher...
Read more >
Types of Attributes in ER Model - GeeksforGeeks
In an Entity-Relation model, attributes are represented in an elliptical shape. Example: Student has attributes like name, age, roll number, ...
Read more >
MongoDB Limits and Thresholds
MongoDB supports no more than 100 levels of nesting for BSON documents. ... For example, you cannot use two databases with names like,...
Read more >
10 Common Hibernate Mistakes That Cripple Your Performance
As you can see the JPQL query and the call of the getBooks method for each of the 12 selected Author entities, caused...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found