Search code examples
spring-bootquerydsl

In operation for StringExpression


I am working on SpringBoot with JPA repository. I am using querydsl for dynamic search criteria.

I am able to implement equals, not equals, like commands.The only issue is with "IN " expression.

Like

public BooleanExpression like(String str) 

Which is working fine. Can anyone suggest to me what I have to use for "IN"

Thanks, Sri.


Solution

  • BooleanExpression is a SimpleExpression which has a method public BooleanExpression in(T... right) that takes a set of values and public BooleanExpression in(Expression<? extends T>... right) that takes a set of expressions.

    You can wrap any Expression in a SimpleExpression using its constructor: new SimpleExpression<>(expression).