objectbox-java icon indicating copy to clipboard operation
objectbox-java copied to clipboard

[ObjectBox] No @Id property found for 'MyClass', add @Id on a not-null long property.

Open TechNov opened this issue 4 years ago • 1 comments

:rotating_light: First, please check:

  • existing issues,
  • Docs https://docs.objectbox.io/
  • Troubleshooting page https://docs.objectbox.io/troubleshooting
  • FAQ page https://docs.objectbox.io/faq

Describe the bug A clear and concise description in English of what the bug is.

Basic info (please complete the following information):

  • ObjectBox version (are you using the latest version?): [e.g. 2.7.0]
  • Reproducibility: [use the modifier 'transient ' on Objectbox default long id ]
  • Device: [Sunmi v2 Pro]
  • OS: [7.1]

Hello, i'm tying to ignore an id protriety in my Gson converto serialization, like this @Entity public class MyClass { @Id transient long id; ...} and a got this error [ObjectBox] No @Id property found for 'MyClass ', add @Id on a not-null long property.

Help.

TechNov avatar Jul 05 '21 19:07 TechNov

If you mark a field as transient ObjectBox will ignore it as well. But every entity class is required to have a @Id property.

Edit: it is best to have a separate model for your database (here ObjectBox) and whatever model you use with Gson to avoid issues like this.

greenrobot-team avatar Jul 13 '21 10:07 greenrobot-team