From cee56a5c421c6a7b8c0e4706f6c99f126b09867a Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Thu, 25 Mar 2021 12:52:38 +0100 Subject: [PATCH] Fix tests for PostgreSQL --- .../orm/test/jdbc/internal/BasicConnectionTest.java | 4 ++-- .../hibernate/orm/test/jdbc/internal/BatchingTest.java | 8 ++++---- .../mapping/converted/converter/AndNationalizedTests.java | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/BasicConnectionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/BasicConnectionTest.java index 03785a9f04..f2cd56b36c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/BasicConnectionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/BasicConnectionTest.java @@ -60,7 +60,7 @@ public class BasicConnectionTest extends BaseCoreFunctionalTestCase { try { Statement statement = jdbcCoord.getStatementPreparer().createStatement(); - String dropSql = getDialect().getDropTableString( "SANDBOX_JDBC_TST" ); + String dropSql = sessionFactory().getJdbcServices().getDialect().getDropTableString( "SANDBOX_JDBC_TST" ); try { jdbcCoord.getResultSetReturn().execute( statement, dropSql ); } @@ -94,7 +94,7 @@ public class BasicConnectionTest extends BaseCoreFunctionalTestCase { session.doWork( connection -> { final Statement stmnt = connection.createStatement(); - stmnt.execute( getDialect().getDropTableString( "SANDBOX_JDBC_TST" ) ); + stmnt.execute( sessionFactory().getJdbcServices().getDialect().getDropTableString( "SANDBOX_JDBC_TST" ) ); } ); } finally { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/BatchingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/BatchingTest.java index 0b40f4c208..46ea00a993 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/BatchingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/internal/BatchingTest.java @@ -58,7 +58,7 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey // set up some tables to use Statement statement = jdbcCoordinator.getStatementPreparer().createStatement(); - String dropSql = getDialect().getDropTableString( "SANDBOX_JDBC_TST" ); + String dropSql = sessionFactory().getJdbcServices().getDialect().getDropTableString( "SANDBOX_JDBC_TST" ); try { jdbcCoordinator.getResultSetReturn().execute( statement, dropSql ); } @@ -117,7 +117,7 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey // set up some tables to use Statement statement = jdbcCoordinator.getStatementPreparer().createStatement(); - String dropSql = getDialect().getDropTableString( "SANDBOX_JDBC_TST" ); + String dropSql = sessionFactory().getJdbcServices().getDialect().getDropTableString( "SANDBOX_JDBC_TST" ); try { jdbcCoordinator.getResultSetReturn().execute( statement, dropSql ); } @@ -188,7 +188,7 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey // set up some tables to use Statement statement = jdbcCoordinator.getStatementPreparer().createStatement(); - String dropSql = getDialect().getDropTableString( "SANDBOX_JDBC_TST" ); + String dropSql = sessionFactory().getJdbcServices().getDialect().getDropTableString( "SANDBOX_JDBC_TST" ); try { jdbcCoordinator.getResultSetReturn().execute( statement, dropSql ); } @@ -266,7 +266,7 @@ public class BatchingTest extends BaseCoreFunctionalTestCase implements BatchKey session.doWork( connection -> { final Statement stmnt = connection.createStatement(); - stmnt.execute( getDialect().getDropTableString( "SANDBOX_JDBC_TST" ) ); + stmnt.execute( sessionFactory().getJdbcServices().getDialect().getDropTableString( "SANDBOX_JDBC_TST" ) ); } ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/AndNationalizedTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/AndNationalizedTests.java index c7c559b773..82f56ebf4f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/AndNationalizedTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/AndNationalizedTests.java @@ -23,6 +23,7 @@ import org.hibernate.dialect.DB2Dialect; import org.hibernate.dialect.DerbyDialect; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.PostgreSQL81Dialect; +import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.mapping.PersistentClass; import org.hibernate.testing.SkipForDialect; @@ -37,7 +38,6 @@ import static org.junit.Assert.assertEquals; * * @author Steve Ebersole */ -//@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "Postgres does not support ") @SkipForDialect(value = DB2Dialect.class, comment = "DB2 jdbc driver doesn't support setNString") public class AndNationalizedTests extends BaseUnitTestCase { @Test @@ -50,15 +50,15 @@ public class AndNationalizedTests extends BaseUnitTestCase { final PersistentClass entityBinding = metadata.getEntityBinding( TestEntity.class.getName() ); final Dialect dialect = metadata.getDatabase().getDialect(); - if ( dialect instanceof PostgreSQL81Dialect - || dialect instanceof DB2Dialect && !( dialect instanceof DerbyDialect ) + if ( dialect instanceof PostgreSQLDialect + || dialect instanceof DB2Dialect || dialect instanceof CockroachDialect ){ // See issue HHH-10693 for PostgreSQL and CockroachDB, HHH-12753 for DB2 assertEquals( Types.VARCHAR, entityBinding.getProperty( "name" ).getType().sqlTypes( metadata )[0] ); - }else { + } else { assertEquals( Types.NVARCHAR, entityBinding.getProperty( "name" ).getType().sqlTypes( metadata )[0]