objectbox / objectbox-java

Android Database - first and fast, lightweight on-device vector database
https://objectbox.io
Apache License 2.0
4.36k stars 301 forks source link

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

Open TechNov opened 3 years ago

TechNov commented 3 years ago

:rotating_light: First, please check:

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

Basic info (please complete the following information):

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.

greenrobot-team commented 3 years ago

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.