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

Combine Query links with or()

Open jrcacd opened this issue 5 years ago • 14 comments

@Entity
public class Note {
    @Id public long id;
    public String title; 
    public ToMany<Tag> tags;
}
 
@Entity
public class Tag {
    @Id public long id;
    public String description;
    public String description2;
}

How to query and return all the results that match the query entered by the user?

noteBox.query()
   .equal(Note_.title, queryString)
  .link(Note_.tags)
   .or()
  .equal(Tag_.description, queryString)
   .or()
  .equal(Tag_.description2, queryString)
  .build()
  .find();

Not working

jrcacd avatar Jul 09 '18 08:07 jrcacd

or condition is currently not supported for 'link' - good point...

greenrobot avatar Jul 09 '18 19:07 greenrobot

It will be included in 2.0?

jrcacd avatar Jul 18 '18 10:07 jrcacd

Didn't make it into 2.0, but should be part of a 2.1-ish release.

greenrobot avatar Jul 25 '18 14:07 greenrobot

???

jrcacd avatar Aug 16 '18 14:08 jrcacd

Sorry to ask, but are you planning to implement this option? That's what we really miss.

jrcacd avatar Dec 17 '18 09:12 jrcacd

Bump

Same issue here; I know the workaround is to aggregate results post-query (and I did that). However, it's still the DBMS' job !

RobbWatershed avatar Jan 27 '19 08:01 RobbWatershed

Same issue here; I know the workaround is to aggregate results post-query (and I did that). However, it's still the DBMS' job !

Agreed, I wrote my own aggregation functionality and it still annoys me.

bigntallmike avatar Mar 09 '20 23:03 bigntallmike

Wonder when that "2.1-ish" will be released, given that 3.0.0 is already released.

mecoFarid avatar Nov 05 '21 13:11 mecoFarid

I am using version 3.1.0 and I still have this problem. It is really strange that the ObjectBox does not support this. This type of query is very common!

hysapp avatar Jan 14 '22 00:01 hysapp

q.link(Trx_.fromAccount).link(Trx_.toAccount)
    .apply(TrxAccount_.name.oneOf(filterOptions.account.toTypedArray()))

I wonder how to do this! Can't proceed without it...

fcat97 avatar Feb 08 '23 19:02 fcat97

Any Idea if its implemented? if not any workaround ?

rahulmaindargi avatar Jul 12 '23 17:07 rahulmaindargi

Combining conditions with or is only supported on the parent object at this point.

If you want us to support combining conditions using or of related objects ("link queries") thumbs up the first comment!

greenrobot-team avatar Jul 31 '23 08:07 greenrobot-team