diff --git a/docker_db.sh b/docker_db.sh index 85035e7f91b8..4715eaa38b1d 100755 --- a/docker_db.sh +++ b/docker_db.sh @@ -186,30 +186,42 @@ edb() { edb_12() { $CONTAINER_CLI rm -f edb || true - # We need to build a derived image because the existing image is mainly made for use by a kubernetes operator - (cd edb; $CONTAINER_CLI build -t edb-test:12 -f edb12.Dockerfile .) - $CONTAINER_CLI run --name edb -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p 5444:5444 -d edb-test:12 + if [[ -z "${DB_IMAGE_EDB}" ]]; then + DB_IMAGE_EDB="edb-test:12" + # We need to build a derived image because the existing image is mainly made for use by a kubernetes operator + (cd edb; $CONTAINER_CLI build -t edb-test:12 -f edb12.Dockerfile .) + fi + $CONTAINER_CLI run --name edb -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p 5444:5444 -d $DB_IMAGE_EDB } edb_14() { $CONTAINER_CLI rm -f edb || true - # We need to build a derived image because the existing image is mainly made for use by a kubernetes operator - (cd edb; $CONTAINER_CLI build -t edb-test:14 -f edb14.Dockerfile .) - $CONTAINER_CLI run --name edb -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p 5444:5444 -d edb-test:14 + if [[ -z "${DB_IMAGE_EDB}" ]]; then + DB_IMAGE_EDB="edb-test:14" + # We need to build a derived image because the existing image is mainly made for use by a kubernetes operator + (cd edb; $CONTAINER_CLI build -t edb-test:14 -f edb14.Dockerfile .) + fi + $CONTAINER_CLI run --name edb -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p 5444:5444 -d $DB_IMAGE_EDB } edb_15() { $CONTAINER_CLI rm -f edb || true - # We need to build a derived image because the existing image is mainly made for use by a kubernetes operator - (cd edb; $CONTAINER_CLI build -t edb-test:15 -f edb15.Dockerfile .) - $CONTAINER_CLI run --name edb -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p 5444:5444 -d edb-test:15 + if [[ -z "${DB_IMAGE_EDB}" ]]; then + DB_IMAGE_EDB="edb-test:15" + # We need to build a derived image because the existing image is mainly made for use by a kubernetes operator + (cd edb; $CONTAINER_CLI build -t edb-test:15 -f edb15.Dockerfile .) + fi + $CONTAINER_CLI run --name edb -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p 5444:5444 -d $DB_IMAGE_EDB } edb_16() { $CONTAINER_CLI rm -f edb || true - # We need to build a derived image because the existing image is mainly made for use by a kubernetes operator - (cd edb; $CONTAINER_CLI build -t edb-test:16 -f edb16.Dockerfile .) - $CONTAINER_CLI run --name edb -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p 5444:5444 -d edb-test:16 + if [[ -z "${DB_IMAGE_EDB}" ]]; then + DB_IMAGE_EDB="edb-test:16" + # We need to build a derived image because the existing image is mainly made for use by a kubernetes operator + (cd edb; $CONTAINER_CLI build -t edb-test:16 -f edb16.Dockerfile .) + fi + $CONTAINER_CLI run --name edb -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p 5444:5444 -d $DB_IMAGE_EDB } db2() { diff --git a/documentation/documentation.gradle b/documentation/documentation.gradle index ad0ee5f00b55..973b3e3e3fd4 100644 --- a/documentation/documentation.gradle +++ b/documentation/documentation.gradle @@ -182,6 +182,7 @@ dependencies { javadocClasspath jakartaLibs.jsonbApi javadocClasspath libs.ant javadocClasspath dbLibs.postgresql + javadocClasspath dbLibs.edb javadocClasspath libs.jackson javadocClasspath gradleApi() javadocClasspath libs.jacksonXml diff --git a/gradle/databases.gradle b/gradle/databases.gradle index 9e4ac21bb51d..a3920c1398a7 100644 --- a/gradle/databases.gradle +++ b/gradle/databases.gradle @@ -79,13 +79,13 @@ ext { ], edb_ci : [ 'db.dialect' : 'org.hibernate.dialect.PostgresPlusDialect', - 'jdbc.driver': 'org.postgresql.Driver', + 'jdbc.driver': 'com.edb.Driver', 'jdbc.user' : 'hibernate_orm_test', 'jdbc.pass' : 'hibernate_orm_test', // Disable prepared statement caching due to https://www.postgresql.org/message-id/CAEcMXhmmRd4-%2BNQbnjDT26XNdUoXdmntV9zdr8%3DTu8PL9aVCYg%40mail.gmail.com - 'jdbc.url' : 'jdbc:postgresql://' + dbHost + '/hibernate_orm_test?preparedStatementCacheQueries=0&escapeSyntaxCallMode=callIfNoReturn', - 'jdbc.datasource' : 'org.postgresql.Driver', -// 'jdbc.datasource' : 'org.postgresql.ds.PGSimpleDataSource', + 'jdbc.url' : 'jdbc:edb://' + dbHost + '/hibernate_orm_test?preparedStatementCacheQueries=0&escapeSyntaxCallMode=callIfNoReturn', + 'jdbc.datasource' : 'com.edb.Driver', +// 'jdbc.datasource' : 'com.edb.ds.PGSimpleDataSource', 'connection.init_sql' : '' ], sybase_ci : [ diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle index a840f90db063..3d44b8fa12cd 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -99,6 +99,7 @@ dependencies { testRuntimeOnly dbLibs.derbyTools testRuntimeOnly dbLibs.hsqldb testRuntimeOnly dbLibs.postgresql + testRuntimeOnly dbLibs.edb testRuntimeOnly dbLibs.mssql testRuntimeOnly dbLibs.informix testRuntimeOnly dbLibs.cockroachdb diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index 689fddb9b73b..8995db8eba19 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -45,6 +45,7 @@ dependencies { compileOnly libs.jackson compileOnly libs.jacksonXml compileOnly dbLibs.postgresql + compileOnly dbLibs.edb testImplementation project(':hibernate-testing') testImplementation project(':hibernate-ant') diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLCastingIntervalSecondJdbcType.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLCastingIntervalSecondJdbcType.java index 5be4dc1bf508..a5508348a008 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLCastingIntervalSecondJdbcType.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLCastingIntervalSecondJdbcType.java @@ -79,7 +79,7 @@ public void appendWriteExpression( Dialect dialect) { appender.append( '(' ); appender.append( writeExpression ); - appender.append( "*interval'1 second)" ); + appender.append( "*interval'1 second')" ); } @Override 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 1baa19a23e8c..5083a0655cc2 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java @@ -179,6 +179,10 @@ private static OptionalTableUpdateStrategy determineOptionalTableUpdateStrategy( : PostgreSQLDialect::withoutMerge; } + public PostgreSQLDriverKind getDriverKind() { + return driverKind; + } + @Override protected DatabaseVersion getMinimumSupportedVersion() { return MINIMUM_VERSION; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/PostgreSQLMultipleTypesOtherContributorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/PostgreSQLMultipleTypesOtherContributorTest.java index ae0599b36ec3..f6fe9cd4f60b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/PostgreSQLMultipleTypesOtherContributorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/PostgreSQLMultipleTypesOtherContributorTest.java @@ -18,15 +18,14 @@ import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.boot.spi.MetadataBuilderContributor; import org.hibernate.boot.spi.MetadataBuilderImplementor; -import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.query.NativeQuery; +import org.hibernate.testing.orm.junit.DialectFeatureChecks; +import org.hibernate.testing.orm.junit.RequiresDialectFeature; import org.hibernate.type.SqlTypes; import org.hibernate.type.spi.TypeConfiguration; -import org.hibernate.testing.RequiresDialect; - import org.hibernate.orm.test.id.usertype.inet.Inet; import org.hibernate.orm.test.id.usertype.inet.InetJavaType; import org.hibernate.orm.test.id.usertype.inet.InetJdbcType; @@ -43,7 +42,7 @@ /** * @author Vlad Mihalcea */ -@RequiresDialect(PostgreSQLDialect.class) +@RequiresDialectFeature(feature = DialectFeatureChecks.IsPgJdbc.class) public class PostgreSQLMultipleTypesOtherContributorTest extends BaseEntityManagerFunctionalTestCase { @Override diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/inet/PostgreSQLInetTypesOtherContributorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/inet/PostgreSQLInetTypesOtherContributorTest.java index 3f66872a1129..1a6d507105e7 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/inet/PostgreSQLInetTypesOtherContributorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/inet/PostgreSQLInetTypesOtherContributorTest.java @@ -12,11 +12,11 @@ import org.hibernate.boot.MetadataBuilder; import org.hibernate.boot.spi.MetadataBuilderContributor; import org.hibernate.boot.spi.MetadataBuilderImplementor; -import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; +import org.hibernate.testing.orm.junit.DialectFeatureChecks; +import org.hibernate.testing.orm.junit.RequiresDialectFeature; import org.hibernate.type.spi.TypeConfiguration; -import org.hibernate.testing.RequiresDialect; import org.junit.Test; import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; @@ -25,7 +25,7 @@ /** * @author Vlad Mihalcea */ -@RequiresDialect(PostgreSQLDialect.class) +@RequiresDialectFeature(feature = DialectFeatureChecks.IsPgJdbc.class) public class PostgreSQLInetTypesOtherContributorTest extends PostgreSQLInetTypesOtherTest { @Override diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/inet/PostgreSQLInetTypesOtherTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/inet/PostgreSQLInetTypesOtherTest.java index c1fc58cec3d4..b25f9dffd85e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/inet/PostgreSQLInetTypesOtherTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/inet/PostgreSQLInetTypesOtherTest.java @@ -11,13 +11,13 @@ import org.hibernate.boot.spi.MetadataBuilderContributor; import org.hibernate.boot.spi.MetadataBuilderImplementor; -import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; import org.hibernate.query.NativeQuery; +import org.hibernate.testing.orm.junit.DialectFeatureChecks; +import org.hibernate.testing.orm.junit.RequiresDialectFeature; import org.hibernate.type.spi.TypeConfiguration; -import org.hibernate.testing.RequiresDialect; import org.junit.Test; import static org.hibernate.testing.transaction.TransactionUtil.doInJPA; @@ -26,7 +26,7 @@ /** * @author Vlad Mihalcea */ -@RequiresDialect(PostgreSQLDialect.class) +@RequiresDialectFeature(feature = DialectFeatureChecks.IsPgJdbc.class) public class PostgreSQLInetTypesOtherTest extends BaseEntityManagerFunctionalTestCase { @Override diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLFunctionProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLFunctionProcedureTest.java index aa03b34248d7..ff8194f996d6 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLFunctionProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLFunctionProcedureTest.java @@ -9,7 +9,6 @@ import java.sql.CallableStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; import java.sql.Timestamp; import java.sql.Types; import java.time.LocalDateTime; @@ -236,34 +235,6 @@ public void testFunctionWithJDBC() { } ); } - @Test - public void testFunctionWithJDBCByName() { - doInJPA( this::entityManagerFactory, entityManager -> { - try { - Session session = entityManager.unwrap( Session.class ); - Long phoneCount = session.doReturningWork( connection -> { - CallableStatement function = null; - try { - function = connection.prepareCall( "{ ? = call fn_count_phones(?) }" ); - function.registerOutParameter( "phoneCount", Types.BIGINT ); - function.setLong( "personId", 1L ); - function.execute(); - return function.getLong( 1 ); - } - finally { - if ( function != null ) { - function.close(); - } - } - } ); - assertEquals( Long.valueOf( 2 ), phoneCount ); - } - catch (Exception e) { - assertEquals( SQLFeatureNotSupportedException.class, e.getCause().getClass() ); - } - } ); - } - @Test @TestForIssue(jiraKey = "HHH-11863") public void testSysRefCursorAsOutParameter() { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLStoredProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLStoredProcedureTest.java index 696125dd75f1..f129cd253475 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLStoredProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/procedure/PostgreSQLStoredProcedureTest.java @@ -9,7 +9,6 @@ import java.sql.CallableStatement; import java.sql.ResultSet; import java.sql.SQLException; -import java.sql.SQLFeatureNotSupportedException; import java.sql.Statement; import java.sql.Timestamp; import java.sql.Types; @@ -120,34 +119,6 @@ public void testStoredProcedureWithJDBC(EntityManagerFactoryScope scope) { } ); } - @Test - public void testProcedureWithJDBCByName(EntityManagerFactoryScope scope) { - scope.inTransaction( entityManager -> { - try { - Session session = entityManager.unwrap( Session.class ); - Long phoneCount = session.doReturningWork( connection -> { - CallableStatement procedure = null; - try { - procedure = connection.prepareCall( "{ call sp_count_phones(?,?) }" ); - procedure.registerOutParameter( "phoneCount", Types.BIGINT ); - procedure.setLong( "personId", 1L ); - procedure.execute(); - return procedure.getLong( 1 ); - } - finally { - if ( procedure != null ) { - procedure.close(); - } - } - } ); - assertEquals( Long.valueOf( 2 ), phoneCount ); - } - catch (Exception e) { - assertEquals( SQLFeatureNotSupportedException.class, e.getCause().getClass() ); - } - } ); - } - @Test @JiraKey("HHH-11863") @RequiresDialect(value = PostgreSQLDialect.class, majorVersion = 14, comment = "Stored procedure OUT parameters are only supported since version 14") diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/PostgresIntervalSecondTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/PostgresIntervalSecondTest.java index cd3c874fbf8d..2f32a016cfe0 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/PostgresIntervalSecondTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/PostgresIntervalSecondTest.java @@ -7,6 +7,7 @@ import org.hibernate.annotations.JdbcTypeCode; import org.hibernate.cfg.AvailableSettings; import org.hibernate.dialect.PostgreSQLDialect; +import org.hibernate.dialect.PostgreSQLCastingIntervalSecondJdbcType; import org.hibernate.dialect.PostgreSQLIntervalSecondJdbcType; import org.hibernate.metamodel.spi.MappingMetamodelImplementor; import org.hibernate.persister.entity.EntityPersister; @@ -55,7 +56,7 @@ public void verifyMappings(SessionFactoryScope scope) { assertThat( durationJdbcType ).isEqualTo( NumericJdbcType.INSTANCE ); final JdbcType intervalType = jdbcTypeRegistry.getDescriptor( SqlTypes.INTERVAL_SECOND ); - assertThat( intervalType ).isOfAnyClassIn( PostgreSQLIntervalSecondJdbcType.class ); + assertThat( intervalType ).isOfAnyClassIn( PostgreSQLIntervalSecondJdbcType.class, PostgreSQLCastingIntervalSecondJdbcType.class ); // a simple duration field with no overrides - so should be using a default JdbcType assertThat( entityDescriptor.findAttributeMapping( "duration" ) diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SharedDriverManagerConnectionProviderImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SharedDriverManagerConnectionProviderImpl.java index b23aa4502d40..2010c5dd7985 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SharedDriverManagerConnectionProviderImpl.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SharedDriverManagerConnectionProviderImpl.java @@ -175,6 +175,49 @@ else if ( "org.postgresql.Driver".equals( config.driverClassName ) ) { } } ); } + else if ( "com.edb.Driver".equals( config.driverClassName ) ) { + validateConnections( c -> { + // Until pgjdbc provides a method for this out of the box, we have to do this manually + // See https://github.com/pgjdbc/pgjdbc/issues/3049 + try { + final Class pgConnection = Class.forName( "com.edb.jdbc.PgConnection" ); + final Object connection = c.unwrap( pgConnection ); + final Object typeInfo = pgConnection.getMethod( "getTypeInfo" ).invoke( connection ); + final Class typeInfoCacheClass = Class.forName( "com.edb.jdbc.TypeInfoCache" ); + final Field oidToPgNameField = typeInfoCacheClass.getDeclaredField( "oidToPgName" ); + final Field pgNameToOidField = typeInfoCacheClass.getDeclaredField( "pgNameToOid" ); + final Field pgNameToSQLTypeField = typeInfoCacheClass.getDeclaredField( "pgNameToSQLType" ); + final Field oidToSQLTypeField = typeInfoCacheClass.getDeclaredField( "oidToSQLType" ); + oidToPgNameField.setAccessible( true ); + pgNameToOidField.setAccessible( true ); + pgNameToSQLTypeField.setAccessible( true ); + oidToSQLTypeField.setAccessible( true ); + //noinspection unchecked + final Map oidToPgName = (Map) oidToPgNameField.get( typeInfo ); + //noinspection unchecked + final Map pgNameToOid = (Map) pgNameToOidField.get( typeInfo ); + //noinspection unchecked + final Map pgNameToSQLType = (Map) pgNameToSQLTypeField.get( typeInfo ); + //noinspection unchecked + final Map oidToSQLType = (Map) oidToSQLTypeField.get( typeInfo ); + for ( Iterator> iter = pgNameToOid.entrySet().iterator(); iter.hasNext(); ) { + Map.Entry entry = iter.next(); + final String typeName = entry.getKey(); + if ( !PGJDBC_STANDARD_TYPE_NAMES.contains( typeName ) ) { + final Integer oid = entry.getValue(); + oidToPgName.remove( oid ); + oidToSQLType.remove( oid ); + pgNameToSQLType.remove( typeName ); + iter.remove(); + } + } + return true; + } + catch (Exception e) { + throw new RuntimeException( e ); + } + } ); + } } public void onDefaultTimeZoneChange() { diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java index 507a8a36c2e1..a764ca743f1a 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/junit4/CustomRunner.java @@ -13,6 +13,7 @@ import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import org.hibernate.dialect.DatabaseVersion; import org.hibernate.dialect.Dialect; @@ -28,7 +29,9 @@ import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialects; import org.hibernate.testing.orm.junit.DialectContext; +import org.hibernate.testing.orm.junit.DialectFeatureCheck; import org.hibernate.testing.orm.junit.DialectFilterExtension; +import org.hibernate.testing.orm.junit.RequiresDialectFeatureGroup; import org.hibernate.testing.orm.junit.SkipForDialectGroup; import org.hibernate.testing.orm.junit.TestingUtil; import org.junit.BeforeClass; @@ -445,6 +448,30 @@ protected Ignore convertSkipToIgnore(FrameworkMethod frameworkMethod) { } } + Collection effectiveRequiresDialectFeatures = Helper.collectAnnotations( + org.hibernate.testing.orm.junit.RequiresDialectFeature.class, + RequiresDialectFeatureGroup.class, + frameworkMethod, + getTestClass() + ); + + for ( org.hibernate.testing.orm.junit.RequiresDialectFeature effectiveRequiresDialectFeature : effectiveRequiresDialectFeatures ) { + try { + final Class featureClass = effectiveRequiresDialectFeature.feature(); + final DialectFeatureCheck featureCheck = featureClass.getConstructor().newInstance(); + boolean testResult = featureCheck.apply( dialect ); + if ( effectiveRequiresDialectFeature.reverse() ) { + testResult = !testResult; + } + if ( !testResult ) { + return buildIgnore( effectiveRequiresDialectFeature ); + } + } + catch (ReflectiveOperationException e) { + throw new RuntimeException( "Unable to instantiate DialectFeatureCheck class", e ); + } + } + return null; } @@ -568,6 +595,14 @@ private Ignore buildIgnore(RequiresDialectFeature requiresDialectFeature) { ); } + private Ignore buildIgnore(org.hibernate.testing.orm.junit.RequiresDialectFeature requiresDialectFeature) { + return buildIgnore( + String.format( Locale.ROOT, "Failed @RequiresDialectFeature [%s]", requiresDialectFeature.feature() ), + requiresDialectFeature.comment(), + requiresDialectFeature.jiraKey() + ); + } + private boolean isMatch(Class condition) { try { Skip.Matcher matcher = condition.newInstance(); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFeatureChecks.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFeatureChecks.java index 1aaca7fa8869..1c0aff5c6835 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFeatureChecks.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DialectFeatureChecks.java @@ -24,6 +24,7 @@ import org.hibernate.dialect.NationalizationSupport; import org.hibernate.dialect.OracleDialect; import org.hibernate.dialect.PostgreSQLDialect; +import org.hibernate.dialect.PostgreSQLDriverKind; import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SpannerDialect; import org.hibernate.dialect.SybaseDialect; @@ -677,6 +678,12 @@ public boolean apply(Dialect dialect) { } } + public static class IsPgJdbc implements DialectFeatureCheck { + public boolean apply(Dialect dialect) { + return dialect instanceof PostgreSQLDialect && ( (PostgreSQLDialect) dialect ).getDriverKind() == PostgreSQLDriverKind.PG_JDBC; + } + } + public static class SupportsCommentOn implements DialectFeatureCheck { public boolean apply(Dialect dialect) { return dialect.supportsCommentOn(); diff --git a/settings.gradle b/settings.gradle index a6a5c3c4e9af..1f00656ab9fe 100644 --- a/settings.gradle +++ b/settings.gradle @@ -242,6 +242,7 @@ dependencyResolutionManagement { def oracleVersion = version "oracle", "23.4.0.24.05" def oracleLegacyVersion = version "oracleLegacy", "11.2.0.4" def pgsqlVersion = version "pgsql", "42.7.1" + def edbVersion = version "edb", "42.7.3.3" def sybaseVersion = version "sybase", "1.3.1" def tidbVersion = version "tidb", mysqlVersion def altibaseVersion = version "altibase", "7.3.0.0.3" @@ -253,6 +254,7 @@ dependencyResolutionManagement { library( "derbyTools", "org.apache.derby", "derbytools" ).versionRef( derbyVersion ) library( "postgresql", "org.postgresql", "postgresql" ).versionRef( pgsqlVersion ) library( "cockroachdb", "org.postgresql", "postgresql" ).versionRef( pgsqlVersion ) + library( "edb", "com.enterprisedb", "edb-jdbc" ).versionRef( edbVersion ) library( "mysql", "com.mysql", "mysql-connector-j" ).versionRef( mysqlVersion ) library( "tidb", "com.mysql", "mysql-connector-j" ).versionRef( tidbVersion ) library( "mariadb", "org.mariadb.jdbc", "mariadb-java-client" ).versionRef( mariadbVersion )