Fix tests for PostgreSQL

This commit is contained in:
Christian Beikov 2021-03-25 12:52:38 +01:00
parent 9c175d0de2
commit cee56a5c42
3 changed files with 10 additions and 10 deletions

View File

@ -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 {

View File

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

View File

@ -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]