Reputation: 470
I am written a predicate query to concat firstname and lastname and compare with entered character.But, I am not able to get the desired result.
QUser user = QUser.suer;
BooleanExpression exp = user.isNotNull();
String received = "Jack Jones"
expression = expression.and((userProfile.firstName.toLowerCase().concat(" " + userProfile.lastName.toLowerCase())).like('%'+(received)+'%'));
I am not getting the record with Jack Joneas when I type in front end. What is need to be done to resolve issue.
Upvotes: 0
Views: 349
Reputation: 857
Your (Java) expression " " + userProfile.lastName.toLowerCase()
calls the toString()
method of the second argument, producing an undefined, fixed String expression instead of a dynamic expression.
What you actually want to achieve is to concatenate 3 parts:
So your last line of code should look like this:
expression = expression.and((userProfile.firstName.toLowerCase().concat(" ").concat(userProfile.lastName.toLowerCase())).like('%'+(received)+'%'));
Upvotes: 1