0

Let's say I have 2 classes defined this way

class A{
    private String name;
}

class B{
    private A a;
    private String bla;
}

And also have predicates for A and B, like this

public static Specification<A> hasName(String name) {
        return (a, cq, cb) -> {
            return cb.and(a.get("name").in(name));
        };
    }

and

public static Specification<B> hasBla(String bla) {
        return (b, cq, cb) -> {
            return cb.and(b.get("bla").in(bla));
        };
    }

Having that both predicates are for different classes, is there a way to use both in the same query? for example, get elements that have the matching name and bla

Camilo Casadiego
  • 907
  • 3
  • 9
  • 33
  • How would that be possible/make any sense? As don't have a `bla` and Bs don't have a `name`? – Jens Schauder Apr 11 '19 at 05:47
  • Don't understand your comment, I have two criteria, one for each class checking its own parameters, then want to mix them in a single query, so with same code, I can query A's by name, B's by bla, or B's for name and bla on separate repo calls – Camilo Casadiego Apr 11 '19 at 12:23

0 Answers0