From 6057d99b79aab9750b1aaac09154af8480d08ae7 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 7 Feb 2024 12:51:51 +0100 Subject: [PATCH] HHH-16454 PostgreSQL ILIKE Keyword is considered a column name when deducing alias injection points --- .../community/dialect/H2LegacyDialect.java | 15 +++++++++++++++ .../java/org/hibernate/dialect/H2Dialect.java | 11 +++++++++++ .../org/hibernate/dialect/PostgreSQLDialect.java | 1 + 3 files changed, 27 insertions(+) diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java index 73bd5da49a1b..76789d08de0c 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/H2LegacyDialect.java @@ -940,4 +940,19 @@ public String rowId(String rowId) { public int rowIdSqlType() { return BIGINT; } + + @Override + public String getCaseInsensitiveLike() { + if ( getVersion().isSameOrAfter( 1, 4, 194 ) ) { + return "ilike"; + } + else { + return super.getCaseInsensitiveLike(); + } + } + + @Override + public boolean supportsCaseInsensitiveLike() { + return getVersion().isSameOrAfter( 1, 4, 194 ); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index 992283b6790a..e21b524406ce 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -935,4 +935,15 @@ public String createMarker(int position, JdbcType jdbcType) { return "?" + position; } } + + @Override + public String getCaseInsensitiveLike() { + return "ilike"; + } + + @Override + public boolean supportsCaseInsensitiveLike(){ + return true; + } + } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java index 2804ca1ecd3d..ccd97ce4c969 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java @@ -153,6 +153,7 @@ public PostgreSQLDialect() { public PostgreSQLDialect(DialectResolutionInfo info) { this( info, PostgreSQLDriverKind.determineKind( info ) ); + registerKeywords( info ); } public PostgreSQLDialect(DatabaseVersion version) {