Skip to content

HHH-15142 Conversion of CriteriaQuery to TypedQuery with Like predicate and escape character fails when repeated. #4970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 26, 2022

Conversation

dreab8
Copy link
Member

@dreab8 dreab8 commented Apr 13, 2022

@dreab8 dreab8 added the 5.6 label Apr 13, 2022
Copy link
Member

@beikov beikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

criteriaBuilder.like(
root.get( Wallet_.model ),
stringValueParameter,
'/'
Copy link
Contributor

@NathanQingyangXu NathanQingyangXu Apr 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong; but it seems the reported issue is preconditioned by 'escaped char', not normal '/' char?
Below is the original code snippet:

CriteriaQuery<Person> criteriaQuery = personQuery      .where(cb.like(
            root.get("name"),
            pattern,
            cb.literal('\\')
      ));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't a syntax error caused by Criteria→JPQL→internal conversion, it happened during parameter binding.
Two other test cases don't have anything about escaping (the use Instant literals), but still fail before the fix.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NathanQingyangXu , I do not think the gist of the issues is this.

Copy link
Contributor

@NathanQingyangXu NathanQingyangXu Apr 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, thanks for letting me know.
It might be an idea to modify the ticket title and description to perfectly remove all misleading irrelevant factors, for future bug reporter might get confused if he searched for similar bugs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by the way I added an additional test

ettavolt and others added 2 commits April 26, 2022 14:54
…java.lang.IllegalArgumentException: Parameter value [] did not match expected type [java.lang.String (n/a)]
@dreab8 dreab8 merged commit ee3129d into hibernate:5.6 Apr 26, 2022
@kguelzau
Copy link

Is there any planned release date for 5.6.9?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants