RushOrm
RushOrm copied to clipboard
Replace list?
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?
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
I think it's working! Thank you!