Skip to content

Allow REGEXP modifier in HQL LIKE predicates. - #4295

Closed
jewoodev wants to merge 1 commit into
spring-projects:mainfrom
jewoodev:hql-like-regexp-parser
Closed

jewoodev wants to merge 1 commit into
spring-projects:mainfrom
jewoodev:hql-like-regexp-parser

Conversation

@jewoodev

@jewoodev jewoodev commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Hibernate's HQL parser accepts LIKE REGEXP and ILIKE REGEXP predicates, but Spring Data JPA's HQL grammar currently treats regexp as the pattern expression and rejects the actual pattern literal.

This change adds REGEXP as an HQL token and allows it as a modifier after LIKE or ILIKE, keeping standalone REGEXP predicates out of scope. HQL renderer round-trip coverage now verifies LIKE REGEXP, NOT LIKE REGEXP, and ILIKE REGEXP.

Verified with ./mvnw -pl spring-data-jpa generate-sources and ./mvnw -pl spring-data-jpa -Dtest=HqlQueryRendererTests test.

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 6, 2026
Hibernate's HQL parser accepts `LIKE REGEXP` and `ILIKE REGEXP` predicates. Align Spring Data JPA's HQL grammar with that syntax and cover the round-trip rendering path.

Signed-off-by: jewoodev <jewoos15@naver.com>
@jewoodev
jewoodev force-pushed the hql-like-regexp-parser branch from f7c1895 to 8d2a260 Compare July 6, 2026 08:26
@jewoodev jewoodev changed the title Allow REGEXP modifier in HQL LIKE predicates. Allow REGEXP modifier in HQL LIKE predicates. Jul 6, 2026
@stupid58fly

Copy link
Copy Markdown
Contributor

Hi @jewoodev

Operators (i?)like regexp works for hibernate 7.2+
But did you check this expression for eclipse link?

Per my understanding, eclipse link supports regexp without (i?)like

@jewoodev

Copy link
Copy Markdown
Contributor Author

EQL parser already supports the standalone form e.name REGEXP 'Jo.*'.

This PR is scoped to Hibernate HQL, did you have a specific interaction with the EQL path in mind that you think this PR should address?

@stupid58fly

Copy link
Copy Markdown
Contributor

No, I just saw your changes and thought about a potential problem.
I am very glad that I was wrong in my assumption.

@mp911de mp911de added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jul 29, 2026
@mp911de mp911de self-assigned this Jul 29, 2026
@mp911de mp911de added this to the 4.0.7 (2025.1.7) milestone Jul 29, 2026
mp911de pushed a commit that referenced this pull request Jul 29, 2026
Hibernate's HQL parser accepts `LIKE REGEXP` and `ILIKE REGEXP` predicates. Align Spring Data JPA's HQL grammar with that syntax and cover the round-trip rendering path.

Signed-off-by: jewoodev <jewoos15@naver.com>
Closes #4295
mp911de added a commit that referenced this pull request Jul 29, 2026
Add ticket test reference.

See #4295
mp911de pushed a commit that referenced this pull request Jul 29, 2026
Hibernate's HQL parser accepts `LIKE REGEXP` and `ILIKE REGEXP` predicates. Align Spring Data JPA's HQL grammar with that syntax and cover the round-trip rendering path.

Signed-off-by: jewoodev <jewoos15@naver.com>
Closes #4295
mp911de added a commit that referenced this pull request Jul 29, 2026
Add ticket test reference.

See #4295
@mp911de mp911de closed this in 7e2c9a7 Jul 29, 2026
mp911de added a commit that referenced this pull request Jul 29, 2026
Add ticket test reference.

See #4295
@mp911de

mp911de commented Jul 29, 2026

Copy link
Copy Markdown
Member

Thank you for your contribution. That's merged, polished, and backported now.

@jewoodev
jewoodev deleted the hql-like-regexp-parser branch August 2, 2026 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants