0
votes

I have the following code, which selects everything in AEntity.

Box<AEntity> a = boxStore.boxFor(AEntity.class);
return new ObjectBoxLiveData<AEntity>(a.query().build());

AEntity has a ToMany relationship with BEntity:

@Backlink(to = "aEntity")
private ToMany<BEntity> bEntities;

I would like to select everything in AEntity as shown above while checking a property of BEntity. The ideal code would look something like this:

Box<AEntity> a = boxStore.boxFor(AEntity.class);
return new ObjectBoxLiveData<AEntity>(a.query().notEqual(BEntity_.bproperty, "-1").build());

Basically I am saying: "I want everything from AEntity as long as bproperty isn't "-1".

Of course, this doesn't work but is there a way I could achieve this behavior?

1

1 Answers

1
votes

Did you try adding a link query for the related entity BEntity? Something like:

queryBuilderA = a.query();
queryBuilderA.link(AEntity_.relation).notEqual(BEntity_.bproperty, -1);
queryBuilderA.build();

https://docs.objectbox.io/queries#add-query-conditions-for-related-entities-links