-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Composite @PrimaryKey from two fields #6108
Comments
Then the primary key field should be a String field that combines the two fields.
|
Duplicate of #1129 |
Has another solution? It is difficult to change type of ID. In whole project I use ID exactly with integer type. |
Shame that you are using |
I change to
|
Here result POJO:
And use:
And now it's work fine. Is it good solution? |
I think it's good solution 👍 |
@Zhuinden Realm internally handles all int as long. |
Here my java pojo in my Android project:
But the id of product is not unique. In table I can have many products with same id. The unique are combination of id and order_id. In table I can have only ONE product with same id AND order_id.
But when I try to add @PrimaryKey to order_id
I get error on Android Studio:
e: error: A class cannot have more than one @PrimaryKey. Both "id" and "order_id" are annotated as @PrimaryKey.
So what I can do?
P.S. I update products by the next method:
The text was updated successfully, but these errors were encountered: