objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence

Home Page:https://docs.objectbox.io/getting-started

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

object put failed: ID is higher or equal to internal ID sequence: 4 (vs. 1). Use ID 0 (zero) to insert new entities. (OBX_ERROR code 10002)

BrinedFish0222 opened this issue · comments

I hope you can help me. Thank you for your help.

An error occurred while put data : Invalid argument(s): object put failed: ID is higher or equal to internal ID sequence: 4 (vs. 1). Use ID 0 (zero) to insert new entities. (OBX_ERROR code 10002)

Basic info

ObjectBox version: 2.2.0
Flutter/Dart SDK: 3.7.0
Reproducible: always
Build OS: Windows 11
Deployment device or OS: ALL

code

  Future<ResponseResult<List<CarouselsEntity>>> loadCarousels() async {
    try {
      final response = await HttpManager.getInstance().get(api: Api.loadCarouselsApi);
      ResponseResult<List<CarouselsEntity>> responseResult = ResponseResult.fromJsonPlus(response, (obj) => CarouselsEntity.fromJsonList(obj as List<dynamic>));
      if (responseResult.isSuccessAndHaveData) {
        DatabaseHelper.instance.deleteAll<CarouselsEntity>();
        // error
        DatabaseHelper.instance.saveBatch<CarouselsEntity>(dataList: responseResult.data);
      }
      return responseResult;
    } catch (e) {
      LogUtil.getInstance().error(e.toString());
      return ResponseResult.error();
    }
  }

error msg:

I/flutter (  382): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (  382): │ #0   LogUtil.error (package:iquant/common/utils/log_util.dart:18:12)
I/flutter (  382): │ #1   CarouselsController.loadCarousels (package:iquant/home/carousels/controller/carousels_controller.dart:25:29)
I/flutter (  382): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (  382): │  Invalid argument(s): object put failed: ID is higher or equal to internal ID sequence: 4

To put new objects, make sure their ObjectBox @Id property is set to 0.

If you need to store an externally provided ID we recommend creating a separate property for that, see the docs for an example.

Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue.