Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Querydsl Like Surprise

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?

like image 726
TheNorthWes Avatar asked Mar 02 '17 17:03

TheNorthWes


1 Answers

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.

like image 156
JRA_TLL Avatar answered Oct 26 '22 08:10

JRA_TLL