From ee7c2ee0416561e17364cb5ea4b965062cb4d22d Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Wed, 19 Oct 2022 19:25:16 +0200 Subject: [PATCH] HHH-15615 Add EDB PostgreSQL Advanced to test matrix and fix issues --- .github/workflows/contributor-build.yml | 1 + Jenkinsfile | 8 +- ci/build.sh | 2 +- ci/database-start.sh | 2 + docker_db.sh | 10 +- edb/Dockerfile | 52 +++ edb/docker-entrypoint.sh | 348 ++++++++++++++++++ gradle/databases.gradle | 3 +- gradle/java-module.gradle | 1 + hibernate-core/hibernate-core.gradle | 1 + .../dataTypes/BasicOperationsTest.java | 3 +- .../orm/test/filter/FilterParameterTests.java | 3 + ...ativeQueryResultTypeAutoDiscoveryTest.java | 2 + .../generated/always/GeneratedAlwaysTest.java | 4 +- .../orm/test/type/DateArrayTest.java | 4 + 15 files changed, 431 insertions(+), 13 deletions(-) create mode 100644 edb/Dockerfile create mode 100755 edb/docker-entrypoint.sh diff --git a/.github/workflows/contributor-build.yml b/.github/workflows/contributor-build.yml index 87d38d2492..7708f9acc5 100644 --- a/.github/workflows/contributor-build.yml +++ b/.github/workflows/contributor-build.yml @@ -43,6 +43,7 @@ jobs: - rdbms: mariadb - rdbms: postgresql - rdbms: postgresql_14 + - rdbms: edb - rdbms: oracle - rdbms: db2 - rdbms: mssql diff --git a/Jenkinsfile b/Jenkinsfile index b728d38884..a83b6fc122 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,6 +34,7 @@ stage('Configure') { // new BuildEnvironment( dbName: 'mariadb' ), // new BuildEnvironment( dbName: 'postgresql' ), // new BuildEnvironment( dbName: 'postgresql_14' ), +// new BuildEnvironment( dbName: 'edb' ), // new BuildEnvironment( dbName: 'oracle' ), // new BuildEnvironment( dbName: 'db2' ), // new BuildEnvironment( dbName: 'mssql' ), @@ -194,12 +195,7 @@ stage('Build') { state[buildEnv.tag]['containerName'] = "sybase" break; case "edb": - docker.withRegistry('https://containers.enterprisedb.com', 'hibernateci.containers.enterprisedb.com') { - // withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'hibernateci.containers.enterprisedb.com', - // usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { - // sh 'docker login -u "$USERNAME" -p "$PASSWORD" https://containers.enterprisedb.com' - docker.image('containers.enterprisedb.com/edb/edb-as-lite:v11').pull() - } + docker.image('quay.io/enterprisedb/edb-postgres-advanced:10.22').pull() sh "./docker_db.sh edb" state[buildEnv.tag]['containerName'] = "edb" break; diff --git a/ci/build.sh b/ci/build.sh index 1b63bcd0de..72a9fa3dfb 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -7,7 +7,7 @@ if [ "$RDBMS" == "h2" ]; then elif [ "$RDBMS" == "derby" ]; then goal="-Pdb=derby" elif [ "$RDBMS" == "edb" ]; then - goal="-Pdb=edb_ci" + goal="-Pdb=edb_ci -DdbHost=localhost:5444" elif [ "$RDBMS" == "hsqldb" ]; then goal="-Pdb=hsqldb" elif [ "$RDBMS" == "mysql8" ]; then diff --git a/ci/database-start.sh b/ci/database-start.sh index ab6f6699c5..62e0bea3bd 100755 --- a/ci/database-start.sh +++ b/ci/database-start.sh @@ -12,6 +12,8 @@ elif [ "$RDBMS" == 'postgresql' ]; then bash $DIR/../docker_db.sh postgresql elif [ "$RDBMS" == 'postgresql_14' ]; then bash $DIR/../docker_db.sh postgresql_14 +elif [ "$RDBMS" == 'edb' ]; then + bash $DIR/../docker_db.sh edb elif [ "$RDBMS" == 'db2' ]; then bash $DIR/../docker_db.sh db2 elif [ "$RDBMS" == 'oracle' ]; then diff --git a/docker_db.sh b/docker_db.sh index 9722e66ceb..ffe63b0543 100755 --- a/docker_db.sh +++ b/docker_db.sh @@ -115,9 +115,15 @@ postgresql_14() { } edb() { - #$CONTAINER_CLI login containers.enterprisedb.com + edb_10 +} + +edb_10() { $CONTAINER_CLI rm -f edb || true - $CONTAINER_CLI run --name edb -e ACCEPT_EULA=Yes -e DATABASE_USER=hibernate_orm_test -e DATABASE_USER_PASSWORD=hibernate_orm_test -e ENTERPRISEDB_PASSWORD=hibernate_orm_test -e DATABASE_NAME=hibernate_orm_test -e PGPORT=5433 -p 5433:5433 --mount type=tmpfs,destination=/edbvolume -d containers.enterprisedb.com/edb/edb-as-lite:v11 + # The version of the base image can be seen and updated in ./edb/Dockerfile + # 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:latest .) + $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:latest } db2() { diff --git a/edb/Dockerfile b/edb/Dockerfile new file mode 100644 index 0000000000..e6610d31b1 --- /dev/null +++ b/edb/Dockerfile @@ -0,0 +1,52 @@ +FROM quay.io/enterprisedb/edb-postgres-advanced:10.22 +USER root +RUN chown -R postgres:postgres /var/lib/edb && chmod 777 /var/lib/edb && mkdir /docker-entrypoint-initdb.d + +#FROM quay.io/enterprisedb/edb-postgres-advanced:11.17-3.2-postgis +#USER root +# this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values) +#RUN chown -R postgres:postgres /var/lib/edb && chmod 777 /var/lib/edb && rm /docker-entrypoint-initdb.d/10_postgis.sh + +USER postgres +ENV LANG en_US.utf8 +ENV PG_MAJOR 10 +ENV PG_VERSION 10 +ENV PGPORT 5444 +ENV PGDATA /var/lib/edb/as$PG_MAJOR/data/ +VOLUME /var/lib/edb/as$PG_MAJOR/data/ + +COPY docker-entrypoint.sh /usr/local/bin/ +ENTRYPOINT ["docker-entrypoint.sh"] + +# We set the default STOPSIGNAL to SIGINT, which corresponds to what PostgreSQL +# calls "Fast Shutdown mode" wherein new connections are disallowed and any +# in-progress transactions are aborted, allowing PostgreSQL to stop cleanly and +# flush tables to disk, which is the best compromise available to avoid data +# corruption. +# +# Users who know their applications do not keep open long-lived idle connections +# may way to use a value of SIGTERM instead, which corresponds to "Smart +# Shutdown mode" in which any existing sessions are allowed to finish and the +# server stops when all sessions are terminated. +# +# See https://www.postgresql.org/docs/12/server-shutdown.html for more details +# about available PostgreSQL server shutdown signals. +# +# See also https://www.postgresql.org/docs/12/server-start.html for further +# justification of this as the default value, namely that the example (and +# shipped) systemd service files use the "Fast Shutdown mode" for service +# termination. +# +STOPSIGNAL SIGINT +# +# An additional setting that is recommended for all users regardless of this +# value is the runtime "--stop-timeout" (or your orchestrator/runtime's +# equivalent) for controlling how long to wait between sending the defined +# STOPSIGNAL and sending SIGKILL (which is likely to cause data corruption). +# +# The default in most runtimes (such as Docker) is 10 seconds, and the +# documentation at https://www.postgresql.org/docs/12/server-start.html notes +# that even 90 seconds may not be long enough in many instances. + +EXPOSE 5444 +CMD ["postgres"] \ No newline at end of file diff --git a/edb/docker-entrypoint.sh b/edb/docker-entrypoint.sh new file mode 100755 index 0000000000..c2bfa83201 --- /dev/null +++ b/edb/docker-entrypoint.sh @@ -0,0 +1,348 @@ +#!/usr/bin/env bash +set -Eeo pipefail +# TODO swap to -Eeuo pipefail above (after handling all potentially-unset variables) + +# usage: file_env VAR [DEFAULT] +# ie: file_env 'XYZ_DB_PASSWORD' 'example' +# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of +# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + export "$var"="$val" + unset "$fileVar" +} + +# check to see if this file is being run or sourced from another script +_is_sourced() { + # https://unix.stackexchange.com/a/215279 + [ "${#FUNCNAME[@]}" -ge 2 ] \ + && [ "${FUNCNAME[0]}" = '_is_sourced' ] \ + && [ "${FUNCNAME[1]}" = 'source' ] +} + +# used to create initial postgres directories and if run as root, ensure ownership to the "postgres" user +docker_create_db_directories() { + local user; user="$(id -u)" + + mkdir -p "$PGDATA" + # ignore failure since there are cases where we can't chmod (and PostgreSQL might fail later anyhow - it's picky about permissions of this directory) + chmod 700 "$PGDATA" || : + + # ignore failure since it will be fine when using the image provided directory; see also https://github.com/docker-library/postgres/pull/289 + mkdir -p /var/run/postgresql || : + chmod 775 /var/run/postgresql || : + + # Create the transaction log directory before initdb is run so the directory is owned by the correct user + if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then + mkdir -p "$POSTGRES_INITDB_WALDIR" + if [ "$user" = '0' ]; then + find "$POSTGRES_INITDB_WALDIR" \! -user postgres -exec chown postgres '{}' + + fi + chmod 700 "$POSTGRES_INITDB_WALDIR" + fi + + # allow the container to be started with `--user` + if [ "$user" = '0' ]; then + find "$PGDATA" \! -user postgres -exec chown postgres '{}' + + find /var/run/postgresql \! -user postgres -exec chown postgres '{}' + + fi +} + +# initialize empty PGDATA directory with new database via 'initdb' +# arguments to `initdb` can be passed via POSTGRES_INITDB_ARGS or as arguments to this function +# `initdb` automatically creates the "postgres", "template0", and "template1" dbnames +# this is also where the database user is created, specified by `POSTGRES_USER` env +docker_init_database_dir() { + # "initdb" is particular about the current user existing in "/etc/passwd", so we use "nss_wrapper" to fake that if necessary + # see https://github.com/docker-library/postgres/pull/253, https://github.com/docker-library/postgres/issues/359, https://cwrap.org/nss_wrapper.html + local uid; uid="$(id -u)" + if ! getent passwd "$uid" &> /dev/null; then + # see if we can find a suitable "libnss_wrapper.so" (https://salsa.debian.org/sssd-team/nss-wrapper/-/commit/b9925a653a54e24d09d9b498a2d913729f7abb15) + local wrapper + for wrapper in {/usr,}/lib{/*,}/libnss_wrapper.so; do + if [ -s "$wrapper" ]; then + NSS_WRAPPER_PASSWD="$(mktemp)" + NSS_WRAPPER_GROUP="$(mktemp)" + export LD_PRELOAD="$wrapper" NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP + local gid; gid="$(id -g)" + echo "postgres:x:$uid:$gid:PostgreSQL:$PGDATA:/bin/false" > "$NSS_WRAPPER_PASSWD" + echo "postgres:x:$gid:" > "$NSS_WRAPPER_GROUP" + break + fi + done + fi + + if [ -n "${POSTGRES_INITDB_WALDIR:-}" ]; then + set -- --waldir "$POSTGRES_INITDB_WALDIR" "$@" + fi + + eval 'initdb --username="$POSTGRES_USER" --pwfile=<(echo "$POSTGRES_PASSWORD") '"$POSTGRES_INITDB_ARGS"' "$@"' + + # unset/cleanup "nss_wrapper" bits + if [[ "${LD_PRELOAD:-}" == */libnss_wrapper.so ]]; then + rm -f "$NSS_WRAPPER_PASSWD" "$NSS_WRAPPER_GROUP" + unset LD_PRELOAD NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP + fi +} + +# print large warning if POSTGRES_PASSWORD is long +# error if both POSTGRES_PASSWORD is empty and POSTGRES_HOST_AUTH_METHOD is not 'trust' +# print large warning if POSTGRES_HOST_AUTH_METHOD is set to 'trust' +# assumes database is not set up, ie: [ -z "$DATABASE_ALREADY_EXISTS" ] +docker_verify_minimum_env() { + # check password first so we can output the warning before postgres + # messes it up + if [ "${#POSTGRES_PASSWORD}" -ge 100 ]; then + cat >&2 <<-'EOWARN' + + WARNING: The supplied POSTGRES_PASSWORD is 100+ characters. + + This will not work if used via PGPASSWORD with "psql". + + https://www.postgresql.org/message-id/flat/E1Rqxp2-0004Qt-PL%40wrigleys.postgresql.org (BUG #6412) + https://github.com/docker-library/postgres/issues/507 + + EOWARN + fi + if [ -z "$POSTGRES_PASSWORD" ] && [ 'trust' != "$POSTGRES_HOST_AUTH_METHOD" ]; then + # The - option suppresses leading tabs but *not* spaces. :) + cat >&2 <<-'EOE' + Error: Database is uninitialized and superuser password is not specified. + You must specify POSTGRES_PASSWORD to a non-empty value for the + superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". + + You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all + connections without a password. This is *not* recommended. + + See PostgreSQL documentation about "trust": + https://www.postgresql.org/docs/current/auth-trust.html + EOE + exit 1 + fi + if [ 'trust' = "$POSTGRES_HOST_AUTH_METHOD" ]; then + cat >&2 <<-'EOWARN' + ******************************************************************************** + WARNING: POSTGRES_HOST_AUTH_METHOD has been set to "trust". This will allow + anyone with access to the Postgres port to access your database without + a password, even if POSTGRES_PASSWORD is set. See PostgreSQL + documentation about "trust": + https://www.postgresql.org/docs/current/auth-trust.html + In Docker's default configuration, this is effectively any other + container on the same system. + + It is not recommended to use POSTGRES_HOST_AUTH_METHOD=trust. Replace + it with "-e POSTGRES_PASSWORD=password" instead to set a password in + "docker run". + ******************************************************************************** + EOWARN + fi +} + +# usage: docker_process_init_files [file [file [...]]] +# ie: docker_process_init_files /always-initdb.d/* +# process initializer files, based on file extensions and permissions +docker_process_init_files() { + # psql here for backwards compatibility "${psql[@]}" + psql=( docker_process_sql ) + + echo + local f + for f; do + case "$f" in + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; + *.sql) echo "$0: running $f"; docker_process_sql -f "$f"; echo ;; + *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;; + *.sql.xz) echo "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;; + *.sql.zst) echo "$0: running $f"; zstd -dc "$f" | docker_process_sql; echo ;; + *) echo "$0: ignoring $f" ;; + esac + echo + done +} + +# Execute sql script, passed via stdin (or -f flag of pqsl) +# usage: docker_process_sql [psql-cli-args] +# ie: docker_process_sql --dbname=mydb <<<'INSERT ...' +# ie: docker_process_sql -f my-file.sql +# ie: docker_process_sql > "$PGDATA/pg_hba.conf" +} + +# start socket-only postgresql server for setting up or running scripts +# all arguments will be passed along as arguments to `postgres` (via pg_ctl) +docker_temp_server_start() { + if [ "$1" = 'postgres' ]; then + shift + fi + + # internal start of server in order to allow setup using psql client + # does not listen on external TCP/IP and waits until start finishes + set -- "$@" -c listen_addresses='' -p "${PGPORT:-5432}" + + PGUSER="${PGUSER:-$POSTGRES_USER}" \ + pg_ctl -D "$PGDATA" \ + -o "$(printf '%q ' "$@")" \ + -w start +} + +# stop postgresql server after done setting up user and running scripts +docker_temp_server_stop() { + PGUSER="${PGUSER:-postgres}" \ + pg_ctl -D "$PGDATA" -m fast -w stop +} + +# check arguments for an option that would cause postgres to stop +# return true if there is one +_pg_want_help() { + local arg + for arg; do + case "$arg" in + # postgres --help | grep 'then exit' + # leaving out -C on purpose since it always fails and is unhelpful: + # postgres: could not access the server configuration file "/var/lib/postgresql/data/postgresql.conf": No such file or directory + -'?'|--help|--describe-config|-V|--version) + return 0 + ;; + esac + done + return 1 +} + +_main() { + # if first arg looks like a flag, assume we want to run postgres server + if [ "${1:0:1}" = '-' ]; then + set -- postgres "$@" + fi + + if [ "$1" = 'postgres' ] && ! _pg_want_help "$@"; then + docker_setup_env + # setup data directories and permissions (when run as root) + docker_create_db_directories + if [ "$(id -u)" = '0' ]; then + # then restart script as postgres user + exec gosu postgres "$BASH_SOURCE" "$@" + fi + + # only run initialization on an empty data directory + if [ -z "$DATABASE_ALREADY_EXISTS" ]; then + docker_verify_minimum_env + + # check dir permissions to reduce likelihood of half-initialized database + ls /docker-entrypoint-initdb.d/ > /dev/null + + docker_init_database_dir + pg_setup_hba_conf "$@" + + # PGPASSWORD is required for psql when authentication is required for 'local' connections via pg_hba.conf and is otherwise harmless + # e.g. when '--auth=md5' or '--auth-local=md5' is used in POSTGRES_INITDB_ARGS + export PGPASSWORD="${PGPASSWORD:-$POSTGRES_PASSWORD}" + docker_temp_server_start "$@" + + echo "setup db" + docker_setup_db + echo "init files" + docker_process_init_files /docker-entrypoint-initdb.d/* + + docker_temp_server_stop + unset PGPASSWORD + + echo + echo 'PostgreSQL init process complete; ready for start up.' + echo + else + echo + echo 'PostgreSQL Database directory appears to contain a database; Skipping initialization' + echo + fi + fi + + exec "$@" +} + +if ! _is_sourced; then + _main "$@" +fi \ No newline at end of file diff --git a/gradle/databases.gradle b/gradle/databases.gradle index 22e89b8a18..d2a41e72ce 100644 --- a/gradle/databases.gradle +++ b/gradle/databases.gradle @@ -10,7 +10,7 @@ import org.apache.tools.ant.filters.ReplaceTokens // build a map of the database settings to use. ext { db = project.hasProperty('db') ? project.getProperty('db') : 'h2' - def dbHost = System.getProperty( 'dbHost', 'localhost' ) + dbHost = System.getProperty( 'dbHost', 'localhost' ) dbBundle = [ h2 : [ 'db.dialect' : 'org.hibernate.dialect.H2Dialect', @@ -353,5 +353,6 @@ ext { def processTestResourcesTask = project.tasks.findByName( 'processTestResources' ) if ( processTestResourcesTask != null ) { processTestResourcesTask.inputs.property( 'db', db ) + processTestResourcesTask.inputs.property( 'dbHost', dbHost ) processTestResourcesTask.filter( ReplaceTokens, tokens: dbBundle[db] ) } \ No newline at end of file diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle index ce0bf030a5..6a60d5f0f8 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -313,6 +313,7 @@ sourceSets { processTestResources { duplicatesStrategy DuplicatesStrategy.INCLUDE inputs.property( "db", db ) + inputs.property( "dbHost", dbHost ) doLast { copy { from( sourceSets.test.java.srcDirs ) { diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index 793e36b327..95e9ba3464 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -134,6 +134,7 @@ xjc { task copyBundleResourcesXml (type: Copy) { inputs.property( "db", db ) + inputs.property( "dbHost", dbHost ) ext { bundlesTargetDir = file( "${buildDir}/bundles" ) // Escape diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/dataTypes/BasicOperationsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/dataTypes/BasicOperationsTest.java index d534af6c57..be521032b2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/dataTypes/BasicOperationsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/dataTypes/BasicOperationsTest.java @@ -16,6 +16,7 @@ import java.util.Locale; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.OracleDialect; +import org.hibernate.dialect.PostgresPlusDialect; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.jdbc.Work; import org.hibernate.type.descriptor.JdbcTypeNameMapper; @@ -56,7 +57,7 @@ public class BasicOperationsTest { public static class OracleDialectChecker implements DialectFeatureCheck { @Override public boolean apply(Dialect dialect) { - return !( dialect instanceof OracleDialect ); + return !( dialect instanceof OracleDialect ) && !( dialect instanceof PostgresPlusDialect ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/filter/FilterParameterTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/filter/FilterParameterTests.java index 5f3d9459c4..f664a020e3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/filter/FilterParameterTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/filter/FilterParameterTests.java @@ -27,6 +27,7 @@ import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.MariaDBDialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.dialect.OracleDialect; +import org.hibernate.dialect.PostgresPlusDialect; import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SybaseDialect; import org.hibernate.dialect.TiDBDialect; @@ -81,6 +82,7 @@ public class FilterParameterTests { @SkipForDialect(dialectClass = SybaseDialect.class, matchSubTypes = true, reason = "Sybase silently converts a boolean to string types") @SkipForDialect(dialectClass = AbstractHANADialect.class, matchSubTypes = true, reason = "HANA silently converts a boolean to string types") @SkipForDialect(dialectClass = CockroachDialect.class, matchSubTypes = true, reason = "Cockroach silently converts a boolean to string types") + @SkipForDialect(dialectClass = PostgresPlusDialect.class, reason = "PostgresPlus silently converts a boolean to string types") public void testYesNoMismatch(SessionFactoryScope scope) { scope.inTransaction( (session) -> { final EntityOne loaded = session.byId( EntityOne.class ).load( 1 ); @@ -150,6 +152,7 @@ public class FilterParameterTests { @SkipForDialect(dialectClass = MySQLDialect.class, reason = "MySQL silently converts strings to integral types") @SkipForDialect(dialectClass = MariaDBDialect.class, reason = "MariaDB silently converts strings to integral types") @SkipForDialect(dialectClass = TiDBDialect.class, reason = "TiDB silently converts strings to integral types") + @SkipForDialect(dialectClass = PostgresPlusDialect.class, reason = "PostgresPlus silently converts strings to integral types") public void testMismatch(SessionFactoryScope scope) { scope.inTransaction( (session) -> { final EntityThree loaded = session.byId( EntityThree.class ).load( 1 ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/NativeQueryResultTypeAutoDiscoveryTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/NativeQueryResultTypeAutoDiscoveryTest.java index 5a6fc2005d..fcae469baf 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/NativeQueryResultTypeAutoDiscoveryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/NativeQueryResultTypeAutoDiscoveryTest.java @@ -35,6 +35,7 @@ import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.dialect.OracleDialect; import org.hibernate.dialect.PostgreSQLDialect; +import org.hibernate.dialect.PostgresPlusDialect; import org.hibernate.dialect.SybaseDialect; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; @@ -273,6 +274,7 @@ public class NativeQueryResultTypeAutoDiscoveryTest { @Test @SkipForDialect(value = OracleDialect.class, comment = "Oracle maps DATE and TIME to TIMESTAMP") + @SkipForDialect(value = PostgresPlusDialect.class, comment = "EDB maps DATE and TIME to TIMESTAMP") public void dateTimeTypes() { createEntityManagerFactory( DateEntity.class, diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/generated/always/GeneratedAlwaysTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/generated/always/GeneratedAlwaysTest.java index d1a4941c0c..45af4bba20 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/generated/always/GeneratedAlwaysTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/generated/always/GeneratedAlwaysTest.java @@ -27,8 +27,8 @@ import static org.junit.Assert.assertEquals; @SkipForDialect(dialectClass = HSQLDialect.class) @SkipForDialect(dialectClass = DerbyDialect.class) @SkipForDialect(dialectClass = SybaseASEDialect.class) -@SkipForDialect(dialectClass = PostgreSQLDialect.class, majorVersion = 10) -@SkipForDialect(dialectClass = PostgreSQLDialect.class, majorVersion = 11) // 'generated always' was added in 12 +@SkipForDialect(dialectClass = PostgreSQLDialect.class, majorVersion = 10, matchSubTypes = true) +@SkipForDialect(dialectClass = PostgreSQLDialect.class, majorVersion = 11, matchSubTypes = true) // 'generated always' was added in 12 public class GeneratedAlwaysTest { @Test diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/DateArrayTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/DateArrayTest.java index c8c5d48fbb..e5c795d2aa 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/DateArrayTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/DateArrayTest.java @@ -12,6 +12,7 @@ import java.time.LocalDate; import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.OracleDialect; +import org.hibernate.dialect.PostgresPlusDialect; import org.hibernate.dialect.SybaseASEDialect; import jakarta.persistence.Column; @@ -106,6 +107,7 @@ public class DateArrayTest extends BaseNonConfigCoreFunctionalTestCase { @Test @SkipForDialect( value = AbstractHANADialect.class, comment = "For some reason, HANA can't intersect VARBINARY values, but funnily can do a union...") + @SkipForDialect( value = PostgresPlusDialect.class, comment = "Seems that comparing date[] through JDBC is buggy. ERROR: operator does not exist: timestamp without time zone[] = date[]") public void testQuery() { inSession( em -> { TypedQuery tq = em.createNamedQuery( "TableWithDateArrays.JPQL.getByData", TableWithDateArrays.class ); @@ -128,6 +130,7 @@ public class DateArrayTest extends BaseNonConfigCoreFunctionalTestCase { @Test @SkipForDialect( value = HSQLDialect.class, comment = "HSQL does not like plain parameters in the distinct from predicate") @SkipForDialect( value = OracleDialect.class, comment = "Oracle requires a special function to compare XML") + @SkipForDialect( value = PostgresPlusDialect.class, comment = "Seems that comparing date[] through JDBC is buggy. ERROR: operator does not exist: timestamp without time zone[] = date[]") public void testNativeQuery() { inSession( em -> { final String op = em.getJdbcServices().getDialect().supportsDistinctFromPredicate() ? "IS NOT DISTINCT FROM" : "="; @@ -143,6 +146,7 @@ public class DateArrayTest extends BaseNonConfigCoreFunctionalTestCase { @Test @RequiresDialectFeature(DialectChecks.SupportsArrayDataTypes.class) + @SkipForDialect( value = PostgresPlusDialect.class, comment = "The 'date' type is a synonym for timestamp on Oracle and PostgresPlus, so untyped reading produces Timestamps") public void testNativeQueryUntyped() { inSession( em -> { Query q = em.createNamedQuery( "TableWithDateArrays.Native.getByIdUntyped" );