New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Realm Update Error #2939
Comments
Hi @rikmenify since your model uses primary key, can you try use Bill updateBill = realm.createObject(Bill.class, bill);
// ...
DetailMenu menu = realm.createObject(DetailMenu.class, menuID);
//...
PersonInMenu pim = realm.createObject(PersonInMenu.class, adapter.getPersonMenuObjList().get(i).getPersonID()); also in your example you're using the same id |
i'm sorry i want to clarify this, even i want to create new object of DetailMenu, i need to use realm.createObject( class, primary key) ? or i can use realm.createObject(class) and i set my primary key after that ? and for the last, i have to use realm.copyToRealmOrUpdate for my updatebill only right ? because i already add all the menu and menuinperson in their parent. please help, because i still confuse about realm concept |
If you have a model class with a primary key, you must provide the value of the primary key when creating an object. The alternative is to create a plain Java object, set the primary key and then copy the object to your Realm. |
so its better with copyToRealmOrUpdate() if i have primary key in my attribute right ? thanks for the support.. |
so i'm updating my code like this
but it's ended with io.realm.exceptions.RealmPrimaryKeyConstraintException: Value already exists: 1 |
|
@rikmenify Please try what @Zhuinden suggests and report back - thanks. |
i've tried it, and i got this error @kneth
i try to get the Log of my Object and there is no null, please help
|
@rikmenify Whoops! My mistake, I forgot to initialize your
|
wait.. i still dont get it why i need to initialize RealmList with that, i created something like this before in my other activity and it worked, i dont know why i need that things you know.. here is the sample i created in my other activity
|
First i already create Bill Object then i try to create updating Object using same ID, because i want to update the realm that have relation to my Bill_ID, but i causes error. it said value already exists,
This is what i try when i want to update
this is my model
The text was updated successfully, but these errors were encountered: