From 3c3aead17bc18f9b5ea8947b5c725a2fa0e682c2 Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Wed, 20 Dec 2023 14:41:51 +0100 Subject: [PATCH] HHH-17303 Fix test on PostgreSQL --- .../hql/joinedSubclass/JoinedSubclassNativeQueryTest.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/joinedSubclass/JoinedSubclassNativeQueryTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/joinedSubclass/JoinedSubclassNativeQueryTest.java index 5277d06354..cb46e74b2d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/joinedSubclass/JoinedSubclassNativeQueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/joinedSubclass/JoinedSubclassNativeQueryTest.java @@ -6,6 +6,7 @@ */ package org.hibernate.orm.test.hql.joinedSubclass; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.type.SqlTypes; @@ -65,6 +66,9 @@ public class JoinedSubclassNativeQueryTest { .getJdbcServices() .getDialect() .getSelectClauseNullString( SqlTypes.VARCHAR, sessionFactory.getTypeConfiguration() ); + // PostgreSQLDialect#getSelectClauseNullString produces e.g. `null::text` which we interpret as parameter, + // so workaround this problem by configuring to ignore JDBC parameters + session.setProperty( AvailableSettings.NATIVE_IGNORE_JDBC_PARAMETERS, true ); Person p = session.createNativeQuery( "select p.*, " + nullColumnString + " as companyName, 0 as clazz_ from Person p", Person.class ).getSingleResult(); Assertions.assertNotNull( p ); Assertions.assertEquals( p.getFirstName(), "Jan" );