RushOrm icon indicating copy to clipboard operation
RushOrm copied to clipboard

Replace list?

Open LimitTech opened this issue 9 years ago • 2 comments

Hello!

I'm using this function in order to replace items from an API REST:

private <T extends Rush> void saveList(List<T> models) {
    for (T model : models) {
        ((Model) model).registerWithId(); // RushCore.getInstance().registerObjectWithId(this, getId()) and getId is public String getId() { return String.valueOf(id); }
    }
    RushCore.getInstance().saveOnlyWithoutConflict(models);
}

And I'm getting android.database.sqlite.SQLiteConstraintException: column rush_id is not unique (code 19) when the app is opened again.

Any ideas?

LimitTech avatar Apr 13 '16 15:04 LimitTech

Hi,

You can't override the getId function.

Once you have called "registerObjectWithId" getId on the base class will return the value you just registered.

I'd try removing the getId function from you class and just changing the register method to this

RushCore.getInstance().registerObjectWithId(this, String.valueOf(id));

Let me know if this works.

Cheers

ghost avatar Apr 15 '16 11:04 ghost

I think it's working! Thank you!

LimitTech avatar Apr 15 '16 13:04 LimitTech