-
Notifications
You must be signed in to change notification settings - Fork 306
Closed
Description
Basics
- ObjectBox version : 0.9.15
- Reproducibility: always
Reproducing the bug
Description
If you have data-models in one package and access them from another package,
and use a ToOne relation in an entity without explicit (and normally redundant) "public"
(since the entity itself is public + as in online documentation)
setTarget etc. don't work, since the ToOne field is package-private you need to explicitly declare "public" ToOne relation in an entity, to get "setTarget" to work.
Code
package com.objectboxtest.model;`
@Entity
public class User {
@Id
long id;
PUBLIC ToOne<Organization> organization;
...
then accessing :
package com.objectboxtest.activities;
...
organization1 = new Organization();
organization1.setName("Organization 1");
organizationsBox.put(organization1);
User user1 = new User();
user1.organization.setTarget(organization1);
....
-> works
Following :
package com.objectboxtest.model;
@Entity
public class User {
@Id
long id;
ToOne<Organization> organization;
...
then accessing
package com.objectboxtest.activities;
...
organization1 = new Organization();
organization1.setName("Organization 1");
organizationsBox.put(organization1);
User user1 = new User();
user1.organization.setTarget(organization1);
....
-> does not work, organization for user 1 is not found, since it's not public
Metadata
Metadata
Assignees
Labels
No labels