Stuart-campbell / RushOrm

Object-relational mapping for Android
http://www.rushorm.co.uk/
Other
172 stars 19 forks source link

Possibility to override Rush Object ID? #127

Closed mladenbabic closed 7 years ago

mladenbabic commented 7 years ago

Hi, I need to override rush id so that I can retrieve data from the server as JSON and converted it as an object, but I don't want to check every time if a similar object exists in rush db. Any chance to override rush id, so in that case, db will make update and not create a new record?

Tnx in advance. Kind regards, Mladen

mladenbabic commented 7 years ago

Ok, I've found a solution with this RushCore.getInstance().registerObjectWithId() method. Is this a right way?

Tnx.

Stuart-campbell commented 7 years ago

Hi,

Yes that will do it make sure you call that before saving the newly created object.

Thanks

mladenbabic commented 7 years ago

With RushCore.getInstance().registerObjectWithId() now I'm getting this error: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: rush_some_object.rush_id. What that means? I guessed that with RushCore.getInstance().registerObjectWithId() will avoid conflicts. The error can not reproduce in some meaningful pattern.

Stuart-campbell commented 7 years ago

Could you have set one of the IDs to null?

mladenbabic commented 7 years ago

Fixed. Tnx