We search by entity, we use Query DSL.
table structure is as follows
TableA : shop -> has manytoOne relationship to TableB : Discount
We need to build a predicate that returns all stores that do not have a
Sale discount , as well as that with a Sale discount.
We use the MySQL and JPA database as our persistence infrastructure.
The scenario is that we do a search and a search to exit all stores without a discount and discount stores.
Below are our Boolean expressions that we currently have.
BooleanExpression A = shop.id.eq(SomeId);
BooleanExpression B = shop.name.eq(SomeName)
BooleanExpression C = shop.discount.isNotNull;
BooleanExpression D = shop.discount.isNull;
BooleanExpression E = shop.disccount.approved.eq(SomeValue)
now we need to build a request to get all stores that do not have a discount, as well as all stores with a discount and approved.
we tried with a predicate
A
.and(B)
.and(D .or(C.and(D).and(E))
)
We expect the request to be
where shop.id=
but generated request
where shop.id=`#someid` and shop.name = `'some name'` and (shop.discount is Null Or shop.discount is not null and shop.approved='`#some Value`')
,
, ? .
Saravana.