Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Entity id and save #36

Open
ChristopheCVB opened this issue Jul 22, 2014 · 2 comments
Open

Entity id and save #36

ChristopheCVB opened this issue Jul 22, 2014 · 2 comments

Comments

@ChristopheCVB
Copy link
Contributor

What if I want to use the same ids used in my server ?
I create a Entity instance specifying my own id, then I save it, ORMDroid throws away my own id and replaces it by last_insert_rowid.
I'm stuck there.
I think I have to create a new field, like cloudId, and use this one when manipulating Entities... Is there any other work around ?

Thanks !

@ChristopheCVB
Copy link
Contributor Author

Maybe using this :
http://stackoverflow.com/questions/418898/sqlite-upsert-not-insert-or-replace/4330694#4330694
in the EntityMapping.insert(SQLiteDatabase db, Entity o)
And when entityInstance.isTransient() == true && entityInstance.getPrimaryKeyValue() != null do not query for the last_insert_rowid(); and return entityInstance.getPrimaryKeyValue(); instead.

What do you think @roscopeco ?

@roscopeco
Copy link
Owner

Internally, the presence of a primary key is used to determine whether the object is transient, so there'd have to be another mechanism for that. Also, how would this work with database constraints? I'm open to taking a look into it though...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants