From e93a07b4f98c71231b3f90a2f87c185e7d810f2d Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Wed, 27 Nov 2024 16:33:40 +0100 Subject: [PATCH] Only cast LONG32 to text on PG to avoid type comparison related issues --- .../hibernate/community/dialect/PostgreSQLLegacyDialect.java | 4 ++-- .../main/java/org/hibernate/dialect/PostgreSQLDialect.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/PostgreSQLLegacyDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/PostgreSQLLegacyDialect.java index e906643aa9..8416fa63cb 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/PostgreSQLLegacyDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/PostgreSQLLegacyDialect.java @@ -199,7 +199,7 @@ public class PostgreSQLLegacyDialect extends Dialect { // "long" string types case LONG32VARCHAR: case LONG32NVARCHAR: - return "text"; + return "varchar"; case BLOB: case CLOB: case NCLOB: @@ -234,7 +234,7 @@ public class PostgreSQLLegacyDialect extends Dialect { case NVARCHAR: case LONG32VARCHAR: case LONG32NVARCHAR: - return "text"; + return "varchar"; case BINARY: case VARBINARY: case LONG32VARBINARY: 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 f4fde81282..7c3ac3f15d 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java @@ -220,7 +220,7 @@ public class PostgreSQLDialect extends Dialect { // since there's no real difference between TEXT and VARCHAR, // except for the length limit, we can just use 'text' for the // "long" string types - case LONG32VARCHAR, LONG32NVARCHAR -> "text"; + case LONG32VARCHAR, LONG32NVARCHAR -> "varchar"; // use oid as the blob/clob type on Postgres because // the JDBC driver doesn't allow using bytea/text via @@ -246,7 +246,7 @@ public class PostgreSQLDialect extends Dialect { @Override protected String castType(int sqlTypeCode) { return switch (sqlTypeCode) { - case CHAR, NCHAR, VARCHAR, NVARCHAR, LONG32VARCHAR, LONG32NVARCHAR -> "text"; + case CHAR, NCHAR, VARCHAR, NVARCHAR, LONG32VARCHAR, LONG32NVARCHAR -> "varchar"; case BINARY, VARBINARY, LONG32VARBINARY -> "bytea"; default -> super.castType( sqlTypeCode ); };