HHH-17303 Fix test on PostgreSQL

This commit is contained in:
Christian Beikov 2023-12-20 14:41:51 +01:00
parent 5f26464c3e
commit 3c3aead17b
1 changed files with 4 additions and 0 deletions

View File

@ -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" );