I have just dabbled into using Querydsl, and am thoroughly enjoying the improvement it brings to interacting with JPA.
One remaining question I have is why do you have to wrap a like
parameter with %
?
Have I improperly configured something? Considering there is a method for starts/endsWith
, I assumed like(str)
would automatically wrap my str
.
But to my surprise I needed to do this: "%" + str + "%"
to get what I had expected.
Why is that? Is there a better way?
Yes, there is. (At least in QueryDSL 4.1.3), there is a contains(String s)
method and variants of it (containsIgnoreCase etc.). This is what you are looking for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With