Fix most tests to work on all DBs and fix a bunch of connection leaks
This commit is contained in:
parent
5d9f6936ff
commit
d767d46d05
|
@ -72,7 +72,9 @@ jobs:
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: test-reports-java8-${{ matrix.rdbms }}
|
name: test-reports-java8-${{ matrix.rdbms }}
|
||||||
path: './**/target/reports/tests/test/'
|
path: |
|
||||||
|
./**/target/reports/tests/
|
||||||
|
./**/target/reports/checkstyle/
|
||||||
- name: Omit produced artifacts from build cache
|
- name: Omit produced artifacts from build cache
|
||||||
run: ./ci/before-cache.sh
|
run: ./ci/before-cache.sh
|
||||||
build11:
|
build11:
|
||||||
|
@ -109,6 +111,8 @@ jobs:
|
||||||
if: failure()
|
if: failure()
|
||||||
with:
|
with:
|
||||||
name: test-reports-java11
|
name: test-reports-java11
|
||||||
path: './**/target/reports/tests/test/'
|
path: |
|
||||||
|
./**/target/reports/tests/
|
||||||
|
./**/target/reports/checkstyle/
|
||||||
- name: Omit produced artifacts from build cache
|
- name: Omit produced artifacts from build cache
|
||||||
run: ./ci/before-cache.sh
|
run: ./ci/before-cache.sh
|
|
@ -3,7 +3,7 @@
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
java -version
|
java -version
|
||||||
./gradlew assemble
|
|
||||||
if [ "$RDBMS" == 'mysql' ]; then
|
if [ "$RDBMS" == 'mysql' ]; then
|
||||||
bash $DIR/../docker_db.sh mysql_5_7
|
bash $DIR/../docker_db.sh mysql_5_7
|
||||||
elif [ "$RDBMS" == 'mysql8' ]; then
|
elif [ "$RDBMS" == 'mysql8' ]; then
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
|
||||||
java -version
|
java -version
|
||||||
./gradlew assemble
|
|
||||||
if [ "$RDBMS" == 'mysql' ]; then
|
if [ "$RDBMS" == 'mysql' ]; then
|
||||||
sudo service mysql stop
|
sudo service mysql stop
|
||||||
bash $DIR/../docker_db.sh mysql_5_7
|
bash $DIR/../docker_db.sh mysql_5_7
|
||||||
|
|
10
ci/build.sh
10
ci/build.sh
|
@ -4,15 +4,15 @@ goal=
|
||||||
if [ "$RDBMS" == "derby" ]; then
|
if [ "$RDBMS" == "derby" ]; then
|
||||||
goal="-Pdb=derby"
|
goal="-Pdb=derby"
|
||||||
elif [ "$RDBMS" == "mariadb" ]; then
|
elif [ "$RDBMS" == "mariadb" ]; then
|
||||||
goal="-Pdb=mariadb"
|
goal="-Pdb=mariadb_ci"
|
||||||
elif [ "$RDBMS" == "postgresql" ]; then
|
elif [ "$RDBMS" == "postgresql" ]; then
|
||||||
goal="-Pdb=pgsql"
|
goal="-Pdb=pgsql_ci"
|
||||||
elif [ "$RDBMS" == "oracle" ]; then
|
elif [ "$RDBMS" == "oracle" ]; then
|
||||||
goal="-Pdb=oracle -Dhibernate.connection.url=jdbc:oracle:thin:@localhost:1521:XE -Dhibernate.connection.username=SYSTEM -Dhibernate.connection.password=Oracle18"
|
goal="-Pdb=oracle_ci"
|
||||||
elif [ "$RDBMS" == "db2" ]; then
|
elif [ "$RDBMS" == "db2" ]; then
|
||||||
goal="-Pdb=db2 -Dhibernate.connection.url=jdbc:db2://localhost:50000/orm_test -Dhibernate.connection.username=orm_test -Dhibernate.connection.password=orm_test"
|
goal="-Pdb=db2_ci"
|
||||||
elif [ "$RDBMS" == "mssql" ]; then
|
elif [ "$RDBMS" == "mssql" ]; then
|
||||||
goal="-Pdb=mssql -Dhibernate.connection.url=jdbc:sqlserver://localhost:1433;databaseName= -Dhibernate.connection.username=sa -Dhibernate.connection.password=hibernate_orm_test"
|
goal="-Pdb=mssql_ci"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec ./gradlew check ${goal} -Plog-test-progress=true --stacktrace
|
exec ./gradlew check ${goal} -Plog-test-progress=true --stacktrace
|
50
docker_db.sh
50
docker_db.sh
|
@ -12,7 +12,7 @@ mysql_8_0() {
|
||||||
|
|
||||||
mariadb() {
|
mariadb() {
|
||||||
docker rm -f mariadb || true
|
docker rm -f mariadb || true
|
||||||
docker run --name mariadb -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -p3306:3306 -d mariadb:10.5.8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
docker run --name mariadb -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -e MYSQL_ROOT_PASSWORD=hibernate_orm_test -p3306:3306 -d mariadb:10.5.8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||||
}
|
}
|
||||||
|
|
||||||
postgresql_9_5() {
|
postgresql_9_5() {
|
||||||
|
@ -22,10 +22,10 @@ postgresql_9_5() {
|
||||||
|
|
||||||
db2() {
|
db2() {
|
||||||
docker rm -f db2 || true
|
docker rm -f db2 || true
|
||||||
docker run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -p 50000:50000 -d ibmcom/db2:11.5.0.0a
|
docker run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -e AUTOCONFIG=false -e ARCHIVE_LOGS=false -e TO_CREATE_SAMPLEDB=false -e REPODB=false -p 50000:50000 -d ibmcom/db2:11.5.5.0
|
||||||
# Give the container some time to start
|
# Give the container some time to start
|
||||||
OUTPUT=
|
OUTPUT=
|
||||||
while [[ $OUTPUT != *"Setup has completed"* ]]; do
|
while [[ $OUTPUT != *"INSTANCE"* ]]; do
|
||||||
echo "Waiting for DB2 to start..."
|
echo "Waiting for DB2 to start..."
|
||||||
sleep 10
|
sleep 10
|
||||||
OUTPUT=$(docker logs db2)
|
OUTPUT=$(docker logs db2)
|
||||||
|
@ -35,7 +35,23 @@ db2() {
|
||||||
|
|
||||||
mssql() {
|
mssql() {
|
||||||
docker rm -f mssql || true
|
docker rm -f mssql || true
|
||||||
docker run --name mssql -d -p 1433:1433 -e "SA_PASSWORD=hibernate_orm_test" -e ACCEPT_EULA=Y microsoft/mssql-server-linux:2017-CU13
|
docker run --name mssql -d -p 1433:1433 -e "SA_PASSWORD=Hibernate_orm_test" -e ACCEPT_EULA=Y microsoft/mssql-server-linux:2017-CU13
|
||||||
|
sleep 5
|
||||||
|
n=0
|
||||||
|
until [ "$n" -ge 5 ]
|
||||||
|
do
|
||||||
|
# We need a database that uses a non-lock based MVCC approach
|
||||||
|
# https://github.com/microsoft/homebrew-mssql-release/issues/2#issuecomment-682285561
|
||||||
|
docker exec mssql bash -c 'echo "create database hibernate_orm_test collate SQL_Latin1_General_CP1_CI_AS; alter database hibernate_orm_test set READ_COMMITTED_SNAPSHOT ON" | /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Hibernate_orm_test -i /dev/stdin' && break
|
||||||
|
echo "Waiting for SQL Server to start..."
|
||||||
|
n=$((n+1))
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
|
if [ "$n" -ge 5 ]; then
|
||||||
|
echo "SQL Server failed to start and configure after 25 seconds"
|
||||||
|
else
|
||||||
|
echo "SQL Server successfully started"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
oracle() {
|
oracle() {
|
||||||
|
@ -43,6 +59,32 @@ oracle() {
|
||||||
# We need to use the defaults
|
# We need to use the defaults
|
||||||
# SYSTEM/Oracle18
|
# SYSTEM/Oracle18
|
||||||
docker run --shm-size=1536m --name oracle -d -p 1521:1521 quillbuilduser/oracle-18-xe
|
docker run --shm-size=1536m --name oracle -d -p 1521:1521 quillbuilduser/oracle-18-xe
|
||||||
|
until [ "`docker inspect -f {{.State.Health.Status}} oracle`" == "healthy" ];
|
||||||
|
do
|
||||||
|
echo "Waiting for Oracle to start..."
|
||||||
|
sleep 10;
|
||||||
|
done
|
||||||
|
echo "Oracle successfully started"
|
||||||
|
# We increase file sizes to avoid online resizes as that requires lots of CPU which is restricted in XE
|
||||||
|
docker exec oracle bash -c "source /home/oracle/.bashrc; bash -c \"
|
||||||
|
cat <<EOF | \$ORACLE_HOME/bin/sqlplus sys/Oracle18@localhost/XE as sysdba
|
||||||
|
alter database tempfile '/opt/oracle/oradata/XE/temp01.dbf' resize 400M;
|
||||||
|
alter database datafile '/opt/oracle/oradata/XE/system01.dbf' resize 1000M;
|
||||||
|
alter database datafile '/opt/oracle/oradata/XE/sysaux01.dbf' resize 600M;
|
||||||
|
alter database datafile '/opt/oracle/oradata/XE/undotbs01.dbf' resize 300M;
|
||||||
|
alter database add logfile group 4 '/opt/oracle/oradata/XE/redo04.log' size 500M reuse;
|
||||||
|
alter database add logfile group 5 '/opt/oracle/oradata/XE/redo05.log' size 500M reuse;
|
||||||
|
alter database add logfile group 6 '/opt/oracle/oradata/XE/redo06.log' size 500M reuse;
|
||||||
|
|
||||||
|
alter system switch logfile;
|
||||||
|
alter system switch logfile;
|
||||||
|
alter system switch logfile;
|
||||||
|
alter system checkpoint;
|
||||||
|
|
||||||
|
alter database drop logfile group 1;
|
||||||
|
alter database drop logfile group 2;
|
||||||
|
alter database drop logfile group 3;
|
||||||
|
EOF\""
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z ${1} ]; then
|
if [ -z ${1} ]; then
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class ListenerTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
//tag::events-jpa-callbacks-example[]
|
//tag::events-jpa-callbacks-example[]
|
||||||
@Entity
|
@Entity(name = "Person")
|
||||||
@EntityListeners( LastUpdateListener.class )
|
@EntityListeners( LastUpdateListener.class )
|
||||||
public static class Person {
|
public static class Person {
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.hibernate.CacheMode;
|
||||||
import org.hibernate.ScrollableResults;
|
import org.hibernate.ScrollableResults;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.MySQL5Dialect;
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
|
@ -1178,6 +1179,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "See https://issues.apache.org/jira/browse/DERBY-2072")
|
||||||
public void test_hql_concat_function_example() {
|
public void test_hql_concat_function_example() {
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
//tag::hql-concat-function-example[]
|
//tag::hql-concat-function-example[]
|
||||||
|
@ -1312,6 +1314,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(SQLServerDialect.class)
|
@SkipForDialect(SQLServerDialect.class)
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Comparisons between 'DATE' and 'TIMESTAMP' are not supported")
|
||||||
public void test_hql_current_date_function_example() {
|
public void test_hql_current_date_function_example() {
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
//tag::hql-current-date-function-example[]
|
//tag::hql-current-date-function-example[]
|
||||||
|
@ -1383,6 +1386,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "See https://issues.apache.org/jira/browse/DERBY-2072")
|
||||||
public void test_hql_cast_function_example() {
|
public void test_hql_cast_function_example() {
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
//tag::hql-cast-function-example[]
|
//tag::hql-cast-function-example[]
|
||||||
|
@ -1396,6 +1400,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't support extract function")
|
||||||
public void test_hql_extract_function_example() {
|
public void test_hql_extract_function_example() {
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
//tag::hql-extract-function-example[]
|
//tag::hql-extract-function-example[]
|
||||||
|
@ -1550,6 +1555,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Comparisons between 'DATE' and 'TIMESTAMP' are not supported")
|
||||||
public void test_hql_collection_expressions_example_7() {
|
public void test_hql_collection_expressions_example_7() {
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
//tag::hql-collection-expressions-example[]
|
//tag::hql-collection-expressions-example[]
|
||||||
|
@ -1565,6 +1571,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Comparisons between 'DATE' and 'TIMESTAMP' are not supported")
|
||||||
public void test_hql_collection_expressions_example_8() {
|
public void test_hql_collection_expressions_example_8() {
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
//tag::hql-collection-expressions-example[]
|
//tag::hql-collection-expressions-example[]
|
||||||
|
|
|
@ -11,6 +11,7 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.Lob;
|
import javax.persistence.Lob;
|
||||||
|
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.MySQL5Dialect;
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
@ -27,9 +28,10 @@ import static org.junit.Assert.assertArrayEquals;
|
||||||
@SkipForDialect(
|
@SkipForDialect(
|
||||||
value = {
|
value = {
|
||||||
PostgreSQL81Dialect.class,
|
PostgreSQL81Dialect.class,
|
||||||
MySQL5Dialect.class
|
MySQL5Dialect.class,
|
||||||
|
DB2Dialect.class
|
||||||
},
|
},
|
||||||
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
|
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695 and https://hibernate.atlassian.net/browse/HHH-10473"
|
||||||
)
|
)
|
||||||
public class NClobCharArrayTest extends BaseEntityManagerFunctionalTestCase {
|
public class NClobCharArrayTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.Lob;
|
import javax.persistence.Lob;
|
||||||
|
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.MySQL5Dialect;
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
@ -27,9 +28,10 @@ import static org.junit.Assert.assertEquals;
|
||||||
@SkipForDialect(
|
@SkipForDialect(
|
||||||
value = {
|
value = {
|
||||||
PostgreSQL81Dialect.class,
|
PostgreSQL81Dialect.class,
|
||||||
MySQL5Dialect.class
|
MySQL5Dialect.class,
|
||||||
|
DB2Dialect.class
|
||||||
},
|
},
|
||||||
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
|
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695 and https://hibernate.atlassian.net/browse/HHH-10473"
|
||||||
)
|
)
|
||||||
public class NClobStringTest extends BaseEntityManagerFunctionalTestCase {
|
public class NClobStringTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.hibernate.Session;
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||||
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.dialect.MySQL5Dialect;
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.engine.jdbc.NClobProxy;
|
import org.hibernate.engine.jdbc.NClobProxy;
|
||||||
|
@ -39,9 +40,10 @@ import static org.junit.Assert.fail;
|
||||||
PostgreSQL81Dialect.class,
|
PostgreSQL81Dialect.class,
|
||||||
MySQL5Dialect.class,
|
MySQL5Dialect.class,
|
||||||
AbstractHANADialect.class,
|
AbstractHANADialect.class,
|
||||||
CockroachDB192Dialect.class
|
CockroachDB192Dialect.class,
|
||||||
|
DB2Dialect.class
|
||||||
},
|
},
|
||||||
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695"
|
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and https://hibernate.atlassian.net/browse/HHH-10695 and https://hibernate.atlassian.net/browse/HHH-10473"
|
||||||
)
|
)
|
||||||
public class NClobTest extends BaseEntityManagerFunctionalTestCase {
|
public class NClobTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
|
@ -24,9 +25,10 @@ import static org.junit.Assert.assertEquals;
|
||||||
*/
|
*/
|
||||||
@SkipForDialect(
|
@SkipForDialect(
|
||||||
value = {
|
value = {
|
||||||
PostgreSQL81Dialect.class
|
PostgreSQL81Dialect.class,
|
||||||
|
DerbyDialect.class
|
||||||
},
|
},
|
||||||
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693"
|
comment = "@see https://hibernate.atlassian.net/browse/HHH-10693 and Derby doesn't support nationalized type"
|
||||||
)
|
)
|
||||||
public class NationalizedTest extends BaseEntityManagerFunctionalTestCase {
|
public class NationalizedTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,10 @@ import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.Subselect;
|
import org.hibernate.annotations.Subselect;
|
||||||
import org.hibernate.annotations.Synchronize;
|
import org.hibernate.annotations.Synchronize;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
|
@ -25,6 +27,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't support a CONCAT function")
|
||||||
public class SubselectTest extends BaseEntityManagerFunctionalTestCase {
|
public class SubselectTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -59,11 +59,11 @@ public class TypeCategoryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class Name {
|
public class Name {
|
||||||
|
|
||||||
private String first;
|
private String firstName;
|
||||||
|
|
||||||
private String middle;
|
private String middleName;
|
||||||
|
|
||||||
private String last;
|
private String lastName;
|
||||||
|
|
||||||
// getters and setters omitted
|
// getters and setters omitted
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
// build a map of the database settings to use.
|
// build a map of the database settings to use.
|
||||||
ext {
|
ext {
|
||||||
db = project.hasProperty('db') ? project.getProperty('db') : 'h2'
|
db = project.hasProperty('db') ? project.getProperty('db') : 'h2'
|
||||||
|
def dbHost = System.getProperty( 'dbHost', 'localhost' )
|
||||||
dbBundle = [
|
dbBundle = [
|
||||||
h2 : [
|
h2 : [
|
||||||
'db.dialect' : 'org.hibernate.dialect.H2Dialect',
|
'db.dialect' : 'org.hibernate.dialect.H2Dialect',
|
||||||
|
@ -42,7 +43,16 @@ ext {
|
||||||
'jdbc.driver': 'org.postgresql.Driver',
|
'jdbc.driver': 'org.postgresql.Driver',
|
||||||
'jdbc.user' : 'hibernate_orm_test',
|
'jdbc.user' : 'hibernate_orm_test',
|
||||||
'jdbc.pass' : 'hibernate_orm_test',
|
'jdbc.pass' : 'hibernate_orm_test',
|
||||||
'jdbc.url' : 'jdbc:postgresql://127.0.0.1/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://127.0.0.1/hibernate_orm_test?preparedStatementCacheQueries=0'
|
||||||
|
],
|
||||||
|
pgsql_ci : [
|
||||||
|
'db.dialect' : 'org.hibernate.dialect.PostgreSQL95Dialect',
|
||||||
|
'jdbc.driver': 'org.postgresql.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'
|
||||||
],
|
],
|
||||||
mysql : [
|
mysql : [
|
||||||
'db.dialect' : 'org.hibernate.dialect.MySQL57Dialect',
|
'db.dialect' : 'org.hibernate.dialect.MySQL57Dialect',
|
||||||
|
@ -65,6 +75,13 @@ ext {
|
||||||
'jdbc.pass' : 'hibernate_orm_test',
|
'jdbc.pass' : 'hibernate_orm_test',
|
||||||
'jdbc.url' : 'jdbc:mariadb://127.0.0.1/hibernate_orm_test'
|
'jdbc.url' : 'jdbc:mariadb://127.0.0.1/hibernate_orm_test'
|
||||||
],
|
],
|
||||||
|
mariadb_ci : [
|
||||||
|
'db.dialect' : 'org.hibernate.dialect.MariaDB103Dialect',
|
||||||
|
'jdbc.driver': 'org.mariadb.jdbc.Driver',
|
||||||
|
'jdbc.user' : 'root',
|
||||||
|
'jdbc.pass' : 'hibernate_orm_test',
|
||||||
|
'jdbc.url' : 'jdbc:mariadb://' + dbHost + '/hibernate_orm_test'
|
||||||
|
],
|
||||||
postgis : [
|
postgis : [
|
||||||
'db.dialect' : 'org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect',
|
'db.dialect' : 'org.hibernate.spatial.dialect.postgis.PostgisPG95Dialect',
|
||||||
'jdbc.driver': 'org.postgresql.Driver',
|
'jdbc.driver': 'org.postgresql.Driver',
|
||||||
|
@ -89,6 +106,13 @@ ext {
|
||||||
'jdbc.pass' : 'Oradoc_db1',
|
'jdbc.pass' : 'Oradoc_db1',
|
||||||
'jdbc.url' : 'jdbc:oracle:thin:@localhost:1521:ORCLCDB'
|
'jdbc.url' : 'jdbc:oracle:thin:@localhost:1521:ORCLCDB'
|
||||||
],
|
],
|
||||||
|
oracle_ci : [
|
||||||
|
'db.dialect' : 'org.hibernate.dialect.Oracle12cDialect',
|
||||||
|
'jdbc.driver': 'oracle.jdbc.OracleDriver',
|
||||||
|
'jdbc.user' : 'SYSTEM',
|
||||||
|
'jdbc.pass' : 'Oracle18',
|
||||||
|
'jdbc.url' : 'jdbc:oracle:thin:@' + dbHost + ':1521:XE'
|
||||||
|
],
|
||||||
mssql : [
|
mssql : [
|
||||||
'db.dialect' : 'org.hibernate.dialect.SQLServer2012Dialect',
|
'db.dialect' : 'org.hibernate.dialect.SQLServer2012Dialect',
|
||||||
'jdbc.driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
|
'jdbc.driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
|
||||||
|
@ -96,6 +120,13 @@ ext {
|
||||||
'jdbc.pass' : 'hibernate_orm_test',
|
'jdbc.pass' : 'hibernate_orm_test',
|
||||||
'jdbc.url' : 'jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=hibernate_orm_test'
|
'jdbc.url' : 'jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=hibernate_orm_test'
|
||||||
],
|
],
|
||||||
|
mssql_ci : [
|
||||||
|
'db.dialect' : 'org.hibernate.dialect.SQLServer2012Dialect',
|
||||||
|
'jdbc.driver': 'com.microsoft.sqlserver.jdbc.SQLServerDriver',
|
||||||
|
'jdbc.user' : 'sa',
|
||||||
|
'jdbc.pass' : 'Hibernate_orm_test',
|
||||||
|
'jdbc.url' : 'jdbc:sqlserver://' + dbHost + ';databaseName=hibernate_orm_test'
|
||||||
|
],
|
||||||
informix : [
|
informix : [
|
||||||
'db.dialect' : 'org.hibernate.dialect.InformixDialect',
|
'db.dialect' : 'org.hibernate.dialect.InformixDialect',
|
||||||
'jdbc.driver': 'com.informix.jdbc.IfxDriver',
|
'jdbc.driver': 'com.informix.jdbc.IfxDriver',
|
||||||
|
@ -110,6 +141,13 @@ ext {
|
||||||
'jdbc.pass' : 'db2inst1-pwd',
|
'jdbc.pass' : 'db2inst1-pwd',
|
||||||
'jdbc.url' : 'jdbc:db2://127.0.0.1:50000/hibern8'
|
'jdbc.url' : 'jdbc:db2://127.0.0.1:50000/hibern8'
|
||||||
],
|
],
|
||||||
|
db2_ci : [
|
||||||
|
'db.dialect' : 'org.hibernate.dialect.DB2Dialect',
|
||||||
|
'jdbc.driver': 'com.ibm.db2.jcc.DB2Driver',
|
||||||
|
'jdbc.user' : 'orm_test',
|
||||||
|
'jdbc.pass' : 'orm_test',
|
||||||
|
'jdbc.url' : 'jdbc:db2://' + dbHost + ':50000/orm_test'
|
||||||
|
],
|
||||||
hana : [
|
hana : [
|
||||||
'db.dialect' : 'org.hibernate.dialect.HANAColumnStoreDialect',
|
'db.dialect' : 'org.hibernate.dialect.HANAColumnStoreDialect',
|
||||||
'jdbc.driver': 'com.sap.db.jdbc.Driver',
|
'jdbc.driver': 'com.sap.db.jdbc.Driver',
|
||||||
|
@ -137,7 +175,8 @@ ext {
|
||||||
'jdbc.driver': 'org.postgresql.Driver',
|
'jdbc.driver': 'org.postgresql.Driver',
|
||||||
'jdbc.user' : 'root',
|
'jdbc.user' : 'root',
|
||||||
'jdbc.pass' : '',
|
'jdbc.pass' : '',
|
||||||
'jdbc.url' : 'jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable'
|
// Disable prepared statement caching due to https://www.postgresql.org/message-id/CAEcMXhmmRd4-%2BNQbnjDT26XNdUoXdmntV9zdr8%3DTu8PL9aVCYg%40mail.gmail.com
|
||||||
|
'jdbc.url' : 'jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable&preparedStatementCacheQueries=0'
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ dependencies {
|
||||||
|
|
||||||
//Databases
|
//Databases
|
||||||
testRuntime( libraries.h2 )
|
testRuntime( libraries.h2 )
|
||||||
|
testRuntime( libraries.derby )
|
||||||
testRuntime( libraries.hsqldb )
|
testRuntime( libraries.hsqldb )
|
||||||
testRuntime( libraries.postgresql )
|
testRuntime( libraries.postgresql )
|
||||||
testRuntime( libraries.mysql )
|
testRuntime( libraries.mysql )
|
||||||
|
@ -89,13 +90,15 @@ dependencies {
|
||||||
|
|
||||||
asciidoclet 'org.asciidoctor:asciidoclet:1.+'
|
asciidoclet 'org.asciidoctor:asciidoclet:1.+'
|
||||||
|
|
||||||
if ( db.equalsIgnoreCase( 'oracle' ) || db.equalsIgnoreCase( 'oracle_docker' ) ) {
|
|
||||||
testRuntime( libraries.oracle )
|
testRuntime( libraries.oracle )
|
||||||
}
|
|
||||||
else if ( db.equalsIgnoreCase( 'db2' ) ) {
|
// Since both the DB2 driver and HANA have a package "net.jpountz" we have to add dependencies conditionally
|
||||||
|
// This is due to the "no split-packages" requirement of Java 9+
|
||||||
|
|
||||||
|
if ( db.startsWith( 'db2' ) ) {
|
||||||
testRuntime( libraries.db2 )
|
testRuntime( libraries.db2 )
|
||||||
}
|
}
|
||||||
else if ( db.equalsIgnoreCase( 'hana' ) ) {
|
else if ( db.startsWith( 'hana' ) ) {
|
||||||
testRuntime( libraries.hana )
|
testRuntime( libraries.hana )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class PreparedStatementSpyConnectionProvider extends AgroalConnectionProv
|
||||||
public void closeConnection(Connection conn) throws SQLException {
|
public void closeConnection(Connection conn) throws SQLException {
|
||||||
acquiredConnections.remove( conn );
|
acquiredConnections.remove( conn );
|
||||||
releasedConnections.add( conn );
|
releasedConnections.add( conn );
|
||||||
super.closeConnection( conn );
|
super.closeConnection( (Connection) MockUtil.getMockSettings( conn ).getSpiedInstance() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,6 +22,7 @@ hibernate.c3p0.testConnectionOnCheckout true
|
||||||
hibernate.show_sql false
|
hibernate.show_sql false
|
||||||
|
|
||||||
hibernate.max_fetch_depth 5
|
hibernate.max_fetch_depth 5
|
||||||
|
hibernate.connection.provider_class C3P0ConnectionProvider
|
||||||
|
|
||||||
hibernate.cache.region_prefix hibernate.test
|
hibernate.cache.region_prefix hibernate.test
|
||||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||||
|
|
|
@ -583,7 +583,7 @@ public class DB2Dialect extends Dialect {
|
||||||
nullPrecedence == NullPrecedence.FIRST ? "0" : "1",
|
nullPrecedence == NullPrecedence.FIRST ? "0" : "1",
|
||||||
nullPrecedence == NullPrecedence.FIRST ? "1" : "0",
|
nullPrecedence == NullPrecedence.FIRST ? "1" : "0",
|
||||||
expression,
|
expression,
|
||||||
order
|
order == null ? "asc" : order
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -608,4 +608,9 @@ public class DerbyDialect extends DB2Dialect {
|
||||||
}
|
}
|
||||||
}, AfterUseAction.CLEAN, null);
|
}, AfterUseAction.CLEAN, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsPartitionBy() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.dialect;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||||
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorMariaDBDatabaseImpl;
|
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorMariaDBDatabaseImpl;
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
||||||
|
@ -42,6 +43,22 @@ public class MariaDB103Dialect extends MariaDB102Dialect {
|
||||||
return "create sequence " + sequenceName;
|
return "create sequence " + sequenceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize)
|
||||||
|
throws MappingException {
|
||||||
|
final String sequenceString = getCreateSequenceString( sequenceName ) + " start with " + initialValue + " increment by " + incrementSize;
|
||||||
|
// MariaDB has defaults for min and max value that don't play well with settings then sign( increment ) != sign( initialValue )
|
||||||
|
if ( incrementSize > 0 && initialValue < 0 ) {
|
||||||
|
return sequenceString + " minvalue " + initialValue;
|
||||||
|
}
|
||||||
|
else if ( incrementSize < 0 && initialValue > 0 ) {
|
||||||
|
return sequenceString + " maxvalue " + initialValue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return sequenceString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDropSequenceString(String sequenceName) {
|
public String getDropSequenceString(String sequenceName) {
|
||||||
return "drop sequence " + sequenceName;
|
return "drop sequence " + sequenceName;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -99,7 +100,8 @@ public class MergeTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "Order")
|
||||||
|
@Table(name = "orders")
|
||||||
private static class Order {
|
private static class Order {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@ -117,7 +119,7 @@ public class MergeTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "Item")
|
||||||
private static class Item {
|
private static class Item {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
|
|
@ -254,14 +254,14 @@ public class TreatKeywordTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "TreatAnimal")
|
||||||
public static abstract class TreatAnimal {
|
public static abstract class TreatAnimal {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private Long id;
|
private Long id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "Dog")
|
||||||
public static abstract class Dog extends TreatAnimal {
|
public static abstract class Dog extends TreatAnimal {
|
||||||
private boolean fast;
|
private boolean fast;
|
||||||
|
|
||||||
|
@ -274,14 +274,14 @@ public class TreatKeywordTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "Dachshund")
|
||||||
public static class Dachshund extends Dog {
|
public static class Dachshund extends Dog {
|
||||||
public Dachshund() {
|
public Dachshund() {
|
||||||
super( false );
|
super( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "Greyhound")
|
||||||
public static class Greyhound extends Dog {
|
public static class Greyhound extends Dog {
|
||||||
public Greyhound() {
|
public Greyhound() {
|
||||||
super( true );
|
super( true );
|
||||||
|
|
|
@ -14,6 +14,7 @@ import javax.persistence.criteria.Path;
|
||||||
import javax.persistence.criteria.Predicate;
|
import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Oracle12cDialect;
|
import org.hibernate.dialect.Oracle12cDialect;
|
||||||
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest;
|
||||||
import org.hibernate.jpa.test.metamodel.CreditCard;
|
import org.hibernate.jpa.test.metamodel.CreditCard;
|
||||||
|
@ -300,6 +301,7 @@ public class PredicateTest extends AbstractMetamodelSpecificTest {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-8901" )
|
@TestForIssue( jiraKey = "HHH-8901" )
|
||||||
@RequiresDialectFeature( DialectChecks.NotSupportsEmptyInListCheck.class )
|
@RequiresDialectFeature( DialectChecks.NotSupportsEmptyInListCheck.class )
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't like `x in (null)`")
|
||||||
public void testEmptyInPredicate() {
|
public void testEmptyInPredicate() {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
|
@ -16,6 +16,7 @@ import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
|
||||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
|
@ -64,11 +65,11 @@ public class CriteriaLiteralWithSingleQuoteTest extends BaseEntityManagerFunctio
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialects(
|
@SkipForDialects(
|
||||||
value = {
|
value = {
|
||||||
|
@SkipForDialect(value = SQLServerDialect.class, comment = "SQLServer does not support literals in group by statement"),
|
||||||
@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL does not support literals in group by statement"),
|
@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL does not support literals in group by statement"),
|
||||||
@SkipForDialect( value = CockroachDB192Dialect.class, comment = "CockroachDB does not support literals in group by statement")
|
@SkipForDialect( value = CockroachDB192Dialect.class, comment = "CockroachDB does not support literals in group by statement")
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL does not support literals in group by statement")
|
|
||||||
public void testLiteralProjectionAndGroupBy() throws Exception {
|
public void testLiteralProjectionAndGroupBy() throws Exception {
|
||||||
doInJPA(
|
doInJPA(
|
||||||
this::entityManagerFactory,
|
this::entityManagerFactory,
|
||||||
|
|
|
@ -17,6 +17,7 @@ import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL95Dialect;
|
import org.hibernate.dialect.PostgreSQL95Dialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.jpa.test.metadata.Person_;
|
import org.hibernate.jpa.test.metadata.Person_;
|
||||||
|
@ -32,6 +33,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@TestForIssue(jiraKey = "HHH-12230")
|
@TestForIssue(jiraKey = "HHH-12230")
|
||||||
@SkipForDialect(value = DB2Dialect.class, comment = "We would need casts in the case clauses. See HHH-12822.")
|
@SkipForDialect(value = DB2Dialect.class, comment = "We would need casts in the case clauses. See HHH-12822.")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby requires either casted parameters or literals in the result arms of CASE expressions")
|
||||||
public class GroupBySelectCaseTest extends BaseEntityManagerFunctionalTestCase {
|
public class GroupBySelectCaseTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,9 +17,12 @@ import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.query.criteria.LiteralHandlingMode;
|
import org.hibernate.query.criteria.LiteralHandlingMode;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -101,6 +104,8 @@ public class SelectCaseLiteralHandlingBindTest extends BaseEntityManagerFunction
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DB2Dialect.class, comment = "We would need casts in the case clauses. See HHH-12822.")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby requires either casted parameters or literals in the result arms of CASE expressions")
|
||||||
public void whereCaseExpression() {
|
public void whereCaseExpression() {
|
||||||
|
|
||||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||||
|
|
|
@ -35,6 +35,7 @@ import javax.persistence.criteria.Predicate;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
@TestForIssue( jiraKey = "HHH-9731" )
|
@TestForIssue( jiraKey = "HHH-9731" )
|
||||||
@SkipForDialect(value = DB2Dialect.class, comment = "We would need casts in the case clauses. See HHH-12822.")
|
@SkipForDialect(value = DB2Dialect.class, comment = "We would need casts in the case clauses. See HHH-12822.")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby requires either casted parameters or literals in the result arms of CASE expressions")
|
||||||
public class SelectCaseTest extends BaseEntityManagerFunctionalTestCase {
|
public class SelectCaseTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -8,11 +8,13 @@ package org.hibernate.jpa.test.metamodel;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
|
@Table(name = "translation_tbl")
|
||||||
public class Translation {
|
public class Translation {
|
||||||
@Id
|
@Id
|
||||||
Integer id;
|
Integer id;
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.hibernate.Hibernate;
|
||||||
import org.hibernate.QueryException;
|
import org.hibernate.QueryException;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL9Dialect;
|
import org.hibernate.dialect.PostgreSQL9Dialect;
|
||||||
import org.hibernate.dialect.PostgresPlusDialect;
|
import org.hibernate.dialect.PostgresPlusDialect;
|
||||||
|
@ -136,6 +137,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to VARCHAR")
|
||||||
public void testNullPositionalParameter() throws Exception {
|
public void testNullPositionalParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -166,6 +168,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to VARCHAR")
|
||||||
public void testNullPositionalParameterParameter() throws Exception {
|
public void testNullPositionalParameterParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -213,6 +216,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to VARCHAR")
|
||||||
public void testNullPositionalParameterParameterIncompatible() throws Exception {
|
public void testNullPositionalParameterParameterIncompatible() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -260,6 +264,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to VARCHAR")
|
||||||
public void testNullNamedParameter() throws Exception {
|
public void testNullNamedParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -290,6 +295,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to VARCHAR")
|
||||||
public void testNullNamedParameterParameter() throws Exception {
|
public void testNullNamedParameterParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -336,6 +342,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to VARCHAR")
|
||||||
public void testNullNamedParameterParameterIncompatible() throws Exception {
|
public void testNullNamedParameterParameterIncompatible() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -386,6 +393,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to INTEGER")
|
||||||
public void testNativeQueryNullPositionalParameter() throws Exception {
|
public void testNativeQueryNullPositionalParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -423,6 +431,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY")
|
@SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to INTEGER")
|
||||||
public void testNativeQueryNullPositionalParameterParameter() throws Exception {
|
public void testNativeQueryNullPositionalParameterParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -476,6 +485,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to INTEGER")
|
||||||
public void testNativeQueryNullNamedParameter() throws Exception {
|
public void testNativeQueryNullNamedParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
@ -513,6 +523,7 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY")
|
@SkipForDialect(value = Oracle8iDialect.class, comment = "ORA-00932: inconsistent datatypes: expected NUMBER got BINARY")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to INTEGER")
|
||||||
public void testNativeQueryNullNamedParameterParameter() throws Exception {
|
public void testNativeQueryNullNamedParameterParameter() throws Exception {
|
||||||
EntityManager em = getOrCreateEntityManager();
|
EntityManager em = getOrCreateEntityManager();
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class JpaSchemaGeneratorTest extends BaseEntityManagerFunctionalTestCase
|
||||||
@TestForIssue(jiraKey = "HHH-8271")
|
@TestForIssue(jiraKey = "HHH-8271")
|
||||||
public void testSqlLoadScriptSourceClasspath() throws Exception {
|
public void testSqlLoadScriptSourceClasspath() throws Exception {
|
||||||
Map settings = buildSettings();
|
Map settings = buildSettings();
|
||||||
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "drop-and-create" );
|
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
|
||||||
settings.put( AvailableSettings.HBM2DDL_LOAD_SCRIPT_SOURCE, getLoadSqlScript() );
|
settings.put( AvailableSettings.HBM2DDL_LOAD_SCRIPT_SOURCE, getLoadSqlScript() );
|
||||||
doTest( settings );
|
doTest( settings );
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class JpaSchemaGeneratorTest extends BaseEntityManagerFunctionalTestCase
|
||||||
@TestForIssue(jiraKey = "HHH-8271")
|
@TestForIssue(jiraKey = "HHH-8271")
|
||||||
public void testSqlLoadScriptSourceUrl() throws Exception {
|
public void testSqlLoadScriptSourceUrl() throws Exception {
|
||||||
Map settings = buildSettings();
|
Map settings = buildSettings();
|
||||||
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "drop-and-create" );
|
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
|
||||||
settings.put( AvailableSettings.HBM2DDL_LOAD_SCRIPT_SOURCE, getResourceUrlString( getLoadSqlScript() ) );
|
settings.put( AvailableSettings.HBM2DDL_LOAD_SCRIPT_SOURCE, getResourceUrlString( getLoadSqlScript() ) );
|
||||||
doTest( settings );
|
doTest( settings );
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class JpaSchemaGeneratorTest extends BaseEntityManagerFunctionalTestCase
|
||||||
@TestForIssue(jiraKey = "HHH-8271")
|
@TestForIssue(jiraKey = "HHH-8271")
|
||||||
public void testSqlCreateScriptSourceClasspath() throws Exception {
|
public void testSqlCreateScriptSourceClasspath() throws Exception {
|
||||||
Map settings = buildSettings();
|
Map settings = buildSettings();
|
||||||
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "drop-and-create" );
|
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
|
||||||
settings.put( AvailableSettings.HBM2DDL_CREATE_SOURCE, "metadata-then-script" );
|
settings.put( AvailableSettings.HBM2DDL_CREATE_SOURCE, "metadata-then-script" );
|
||||||
settings.put( AvailableSettings.HBM2DDL_CREATE_SCRIPT_SOURCE, getCreateSqlScript() );
|
settings.put( AvailableSettings.HBM2DDL_CREATE_SCRIPT_SOURCE, getCreateSqlScript() );
|
||||||
doTest( settings );
|
doTest( settings );
|
||||||
|
@ -89,7 +89,7 @@ public class JpaSchemaGeneratorTest extends BaseEntityManagerFunctionalTestCase
|
||||||
@TestForIssue(jiraKey = "HHH-8271")
|
@TestForIssue(jiraKey = "HHH-8271")
|
||||||
public void testSqlCreateScriptSourceUrl() throws Exception {
|
public void testSqlCreateScriptSourceUrl() throws Exception {
|
||||||
Map settings = buildSettings();
|
Map settings = buildSettings();
|
||||||
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "drop-and-create" );
|
settings.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
|
||||||
settings.put( AvailableSettings.HBM2DDL_CREATE_SOURCE, "metadata-then-script" );
|
settings.put( AvailableSettings.HBM2DDL_CREATE_SOURCE, "metadata-then-script" );
|
||||||
settings.put( AvailableSettings.HBM2DDL_CREATE_SCRIPT_SOURCE, getResourceUrlString( getCreateSqlScript() ) );
|
settings.put( AvailableSettings.HBM2DDL_CREATE_SCRIPT_SOURCE, getResourceUrlString( getCreateSqlScript() ) );
|
||||||
doTest( settings );
|
doTest( settings );
|
||||||
|
|
|
@ -165,6 +165,11 @@ public class FlushAndTransactionTest extends BaseEntityManagerFunctionalTestCase
|
||||||
catch ( IllegalStateException e ) {
|
catch ( IllegalStateException e ) {
|
||||||
//success
|
//success
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
if ( em.getTransaction().isActive() ) {
|
||||||
|
em.getTransaction().rollback();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -75,7 +75,9 @@ public class JtaWithFailingBatchTest extends AbstractJtaBatchTest {
|
||||||
}
|
}
|
||||||
catch (Exception expected) {
|
catch (Exception expected) {
|
||||||
//expected
|
//expected
|
||||||
if ( transactionManager.getStatus() == Status.STATUS_ACTIVE ) {
|
switch ( transactionManager.getStatus() ) {
|
||||||
|
case Status.STATUS_ACTIVE:
|
||||||
|
case Status.STATUS_MARKED_ROLLBACK:
|
||||||
transactionManager.rollback();
|
transactionManager.rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +91,6 @@ public class JtaWithFailingBatchTest extends AbstractJtaBatchTest {
|
||||||
assertStatementsListIsCleared();
|
assertStatementsListIsCleared();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|
||||||
em.close();
|
em.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,9 @@ import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.ParameterExpression;
|
import javax.persistence.criteria.ParameterExpression;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -92,6 +95,7 @@ public class BasicCriteriaExecutionTests extends BaseNonConfigCoreFunctionalTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't support comparing parameters against each other")
|
||||||
public void testExecutingBasicCriteriaQueryParameterPredicate() {
|
public void testExecutingBasicCriteriaQueryParameterPredicate() {
|
||||||
final CriteriaBuilder criteriaBuilder = sessionFactory().getCriteriaBuilder();
|
final CriteriaBuilder criteriaBuilder = sessionFactory().getCriteriaBuilder();
|
||||||
|
|
||||||
|
@ -111,6 +115,7 @@ public class BasicCriteriaExecutionTests extends BaseNonConfigCoreFunctionalTest
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't support comparing parameters against each other")
|
||||||
public void testExecutingBasicCriteriaQueryParameterPredicateInStatelessSession() {
|
public void testExecutingBasicCriteriaQueryParameterPredicateInStatelessSession() {
|
||||||
final CriteriaBuilder criteriaBuilder = sessionFactory().getCriteriaBuilder();
|
final CriteriaBuilder criteriaBuilder = sessionFactory().getCriteriaBuilder();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ import javax.persistence.criteria.Path;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ public class SearchedCaseExpressionTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(value = DB2Dialect.class, comment = "We would need casts in the case clauses. See HHH-12822.")
|
@SkipForDialect(value = DB2Dialect.class, comment = "We would need casts in the case clauses. See HHH-12822.")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby requires either casted parameters or literals in the result arms of CASE expressions")
|
||||||
public void testEqualClause() {
|
public void testEqualClause() {
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
CriteriaBuilder cb = session.getCriteriaBuilder();
|
CriteriaBuilder cb = session.getCriteriaBuilder();
|
||||||
|
@ -89,6 +91,8 @@ public class SearchedCaseExpressionTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-13167")
|
@TestForIssue(jiraKey = "HHH-13167")
|
||||||
|
@SkipForDialect(value = DB2Dialect.class, comment = "We would need casts in the case clauses. See HHH-12822.")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby requires either casted parameters or literals in the result arms of CASE expressions")
|
||||||
public void testMissingElseClause() {
|
public void testMissingElseClause() {
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
Event event = new Event();
|
Event event = new Event();
|
||||||
|
|
|
@ -7,6 +7,10 @@ import javax.persistence.EmbeddedId;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -24,6 +28,8 @@ public class HHH14156Test extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = SQLServerDialect.class, comment = "SQLServer doesn't support tuple comparisons")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't support tuple comparisons")
|
||||||
public void testNoExceptionThrown() {
|
public void testNoExceptionThrown() {
|
||||||
inTransaction( session ->
|
inTransaction( session ->
|
||||||
session.createQuery(
|
session.createQuery(
|
||||||
|
|
|
@ -161,7 +161,7 @@ public class JaccIntegratorTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "Person")
|
||||||
public static class Person {
|
public static class Person {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
|
|
@ -33,6 +33,7 @@ public class EmbeddableWithOneToMany_HHH_11302_xml_Test extends
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void buildEntityManagerFactory() {
|
public void buildEntityManagerFactory() {
|
||||||
try {
|
try {
|
||||||
super.buildEntityManagerFactory();
|
super.buildEntityManagerFactory();
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class LobTest extends BaseCoreFunctionalTestCase {
|
||||||
entity.setQwerty(randomString(4000));
|
entity.setQwerty(randomString(4000));
|
||||||
session.save(entity);
|
session.save(entity);
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
session.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -60,5 +61,7 @@ public class LobTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
String s = (String) query.uniqueResult();
|
String s = (String) query.uniqueResult();
|
||||||
log.debug( "Using Oracle charset " + s );
|
log.debug( "Using Oracle charset " + s );
|
||||||
|
session.getTransaction().commit();
|
||||||
|
session.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL9Dialect;
|
import org.hibernate.dialect.PostgreSQL9Dialect;
|
||||||
|
@ -121,6 +122,7 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to BIGINT")
|
||||||
public void testQueryWithNullParameter(){
|
public void testQueryWithNullParameter(){
|
||||||
Chaos c0 = new Chaos();
|
Chaos c0 = new Chaos();
|
||||||
c0.setId( 0L );
|
c0.setId( 0L );
|
||||||
|
@ -207,6 +209,7 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase {
|
||||||
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = PostgresPlusDialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
@SkipForDialect(value = CockroachDB192Dialect.class, jiraKey = "HHH-10312", comment = "Cannot convert untyped null (assumed to be bytea type) to bigint")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Null == null on Sybase")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to BIGINT")
|
||||||
public void testNativeQueryWithNullParameter(){
|
public void testNativeQueryWithNullParameter(){
|
||||||
Chaos c0 = new Chaos();
|
Chaos c0 = new Chaos();
|
||||||
c0.setId( 0L );
|
c0.setId( 0L );
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
package org.hibernate.test.bulkid;
|
package org.hibernate.test.bulkid;
|
||||||
|
|
||||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
|
||||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
|
||||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||||
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@RequiresDialect(PostgreSQL82Dialect.class)
|
@RequiresDialectFeature(DialectChecks.SupportsGlobalTemporaryTables.class)
|
||||||
@SkipForDialect(value = CockroachDB192Dialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/5807")
|
|
||||||
public class GlobalTemporaryTableBulkCompositeIdTest extends AbstractBulkCompositeIdTest {
|
public class GlobalTemporaryTableBulkCompositeIdTest extends AbstractBulkCompositeIdTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,6 +14,7 @@ import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -102,7 +103,8 @@ public class MergeTest extends BaseCoreFunctionalTestCase {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "Order")
|
||||||
|
@Table(name = "orders")
|
||||||
private static class Order {
|
private static class Order {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
@ -120,7 +122,7 @@ public class MergeTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "Item")
|
||||||
private static class Item {
|
private static class Item {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
|
|
|
@ -178,17 +178,17 @@ public class QueryTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public static class Name {
|
public static class Name {
|
||||||
public String first;
|
public String firstName;
|
||||||
public String middle;
|
public String middleName;
|
||||||
public String last;
|
public String lastName;
|
||||||
|
|
||||||
public Name() {
|
public Name() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Name(String first, String middle, String last) {
|
public Name(String firstName, String middleName, String lastName) {
|
||||||
this.first = first;
|
this.firstName = firstName;
|
||||||
this.middle = middle;
|
this.middleName = middleName;
|
||||||
this.last = last;
|
this.lastName = lastName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -135,6 +135,7 @@ public class BeforeCompletionReleaseTest extends BaseEntityManagerFunctionalTest
|
||||||
inOrder.verify( statementMock ).close();
|
inOrder.verify( statementMock ).close();
|
||||||
inOrder.verify( connectionSpy ).close();
|
inOrder.verify( connectionSpy ).close();
|
||||||
inOrder.verify( transactionSpy ).commit( any(), anyBoolean() );
|
inOrder.verify( transactionSpy ).commit( any(), anyBoolean() );
|
||||||
|
Mockito.reset( connectionSpy );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spyOnTransaction(XAResource xaResource) {
|
private void spyOnTransaction(XAResource xaResource) {
|
||||||
|
|
|
@ -27,6 +27,9 @@ import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.internal.util.MockUtil;
|
||||||
|
|
||||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
|
@ -92,6 +95,7 @@ public class ConnectionsReleaseAutoCommitTest extends BaseEntityManagerFunctiona
|
||||||
|
|
||||||
assertEquals( 1, connectionProvider.getConnectionCount() );
|
assertEquals( 1, connectionProvider.getConnectionCount() );
|
||||||
verify( connectionProvider.connection, times( 1 ) ).close();
|
verify( connectionProvider.connection, times( 1 ) ).close();
|
||||||
|
Mockito.reset( connectionProvider.connection );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name = "Thing")
|
@Entity(name = "Thing")
|
||||||
|
|
|
@ -20,8 +20,12 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -34,6 +38,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
//@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "Postgres does not support ")
|
//@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 {
|
public class AndNationalizedTests extends BaseUnitTestCase {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-9599")
|
@TestForIssue( jiraKey = "HHH-9599")
|
||||||
|
@ -44,9 +49,10 @@ public class AndNationalizedTests extends BaseUnitTestCase {
|
||||||
( (MetadataImpl) metadata ).validate();
|
( (MetadataImpl) metadata ).validate();
|
||||||
|
|
||||||
final PersistentClass entityBinding = metadata.getEntityBinding( TestEntity.class.getName() );
|
final PersistentClass entityBinding = metadata.getEntityBinding( TestEntity.class.getName() );
|
||||||
if(metadata.getDatabase().getDialect() instanceof PostgreSQL81Dialect
|
final Dialect dialect = metadata.getDatabase().getDialect();
|
||||||
|| metadata.getDatabase().getDialect() instanceof DB2Dialect
|
if ( dialect instanceof PostgreSQL81Dialect
|
||||||
|| metadata.getDatabase().getDialect() instanceof CockroachDB192Dialect){
|
|| dialect instanceof DB2Dialect && !( dialect instanceof DerbyDialect )
|
||||||
|
|| dialect instanceof CockroachDB192Dialect){
|
||||||
// See issue HHH-10693 for PostgreSQL and CockroachDB, HHH-12753 for DB2
|
// See issue HHH-10693 for PostgreSQL and CockroachDB, HHH-12753 for DB2
|
||||||
assertEquals(
|
assertEquals(
|
||||||
Types.VARCHAR,
|
Types.VARCHAR,
|
||||||
|
|
|
@ -14,8 +14,11 @@ import java.util.List;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
|
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -50,6 +53,7 @@ public class InTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-8901" )
|
@TestForIssue( jiraKey = "HHH-8901" )
|
||||||
@RequiresDialectFeature(DialectChecks.NotSupportsEmptyInListCheck.class)
|
@RequiresDialectFeature(DialectChecks.NotSupportsEmptyInListCheck.class)
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't like `x in (null)`")
|
||||||
public void testEmptyInListForDialectNotSupportsEmptyInList() {
|
public void testEmptyInListForDialectNotSupportsEmptyInList() {
|
||||||
Session session = openSession();
|
Session session = openSession();
|
||||||
Transaction tx = session.beginTransaction();
|
Transaction tx = session.beginTransaction();
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.Criteria;
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
|
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
|
@ -30,6 +31,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
*/
|
*/
|
||||||
@TestForIssue( jiraKey = "HHH-8657" )
|
@TestForIssue( jiraKey = "HHH-8657" )
|
||||||
@SkipForDialect(value = DB2Dialect.class, comment = "DB2 jdbc driver doesn't support setNString")
|
@SkipForDialect(value = DB2Dialect.class, comment = "DB2 jdbc driver doesn't support setNString")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby jdbc driver doesn't support setNString")
|
||||||
@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL jdbc driver doesn't support setNString")
|
@SkipForDialect(value = PostgreSQL81Dialect.class, comment = "PostgreSQL jdbc driver doesn't support setNString")
|
||||||
public class NationalizedIgnoreCaseTest extends BaseCoreFunctionalTestCase {
|
public class NationalizedIgnoreCaseTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
|
|
|
@ -22,11 +22,14 @@ import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.dialect.SQLServer2005Dialect;
|
import org.hibernate.dialect.SQLServer2005Dialect;
|
||||||
|
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.hibernate.testing.transaction.TransactionUtil;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
@ -55,20 +58,32 @@ public class SQLServerDialectCollationTest extends BaseCoreFunctionalTestCase {
|
||||||
StandardServiceRegistryImpl _serviceRegistry = buildServiceRegistry( bootRegistry, constructConfiguration() );
|
StandardServiceRegistryImpl _serviceRegistry = buildServiceRegistry( bootRegistry, constructConfiguration() );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try (Connection connection = _serviceRegistry.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess().obtainConnection();
|
try {
|
||||||
Statement statement = connection.createStatement()) {
|
TransactionUtil.doWithJDBC(
|
||||||
|
_serviceRegistry,
|
||||||
|
connection -> {
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
connection.setAutoCommit( true );
|
connection.setAutoCommit( true );
|
||||||
statement.executeUpdate( "DROP DATABASE hibernate_orm_test_collation" );
|
statement.executeUpdate( "DROP DATABASE hibernate_orm_test_collation" );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
log.debug( e.getMessage() );
|
log.debug( e.getMessage() );
|
||||||
}
|
}
|
||||||
try (Connection connection = _serviceRegistry.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess().obtainConnection();
|
try {
|
||||||
Statement statement = connection.createStatement()) {
|
TransactionUtil.doWithJDBC(
|
||||||
|
_serviceRegistry,
|
||||||
|
connection -> {
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
connection.setAutoCommit( true );
|
connection.setAutoCommit( true );
|
||||||
statement.executeUpdate( "CREATE DATABASE hibernate_orm_test_collation COLLATE Latin1_General_CS_AS" );
|
statement.executeUpdate( "CREATE DATABASE hibernate_orm_test_collation COLLATE Latin1_General_CS_AS" );
|
||||||
statement.executeUpdate( "ALTER DATABASE [hibernate_orm_test_collation] SET AUTO_CLOSE OFF " );
|
statement.executeUpdate( "ALTER DATABASE [hibernate_orm_test_collation] SET AUTO_CLOSE OFF " );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
log.debug( e.getMessage() );
|
log.debug( e.getMessage() );
|
||||||
}
|
}
|
||||||
|
@ -148,7 +163,6 @@ public class SQLServerDialectCollationTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean rebuildSessionFactoryOnError() {
|
protected boolean rebuildSessionFactoryOnError() {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.dialect.functional;
|
package org.hibernate.test.dialect.functional;
|
||||||
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
@ -21,12 +20,12 @@ import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.dialect.SQLServer2005Dialect;
|
import org.hibernate.dialect.SQLServer2005Dialect;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
|
||||||
|
|
||||||
import org.hibernate.testing.AfterClassOnce;
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.hibernate.testing.transaction.TransactionUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -50,20 +49,34 @@ public class SQLServerDialectTempTableCollationTest extends BaseCoreFunctionalTe
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClassOnce
|
@Override
|
||||||
protected void revertBackOriginalDBCollation() {
|
protected void releaseSessionFactory() {
|
||||||
|
super.releaseSessionFactory();
|
||||||
if ( originalDBCollation != null && collationChanged && !changedDBCollation.equals( originalDBCollation ) ) {
|
if ( originalDBCollation != null && collationChanged && !changedDBCollation.equals( originalDBCollation ) ) {
|
||||||
BootstrapServiceRegistry bootRegistry = buildBootstrapServiceRegistry();
|
BootstrapServiceRegistry bootRegistry = buildBootstrapServiceRegistry();
|
||||||
StandardServiceRegistryImpl serviceRegistry = buildServiceRegistry(
|
StandardServiceRegistryImpl serviceRegistry = buildServiceRegistry(
|
||||||
bootRegistry,
|
bootRegistry,
|
||||||
constructConfiguration()
|
constructConfiguration()
|
||||||
);
|
);
|
||||||
try (Connection connection = serviceRegistry.getService( JdbcServices.class )
|
try {
|
||||||
.getBootstrapJdbcConnectionAccess()
|
TransactionUtil.doWithJDBC(
|
||||||
.obtainConnection();
|
serviceRegistry,
|
||||||
Statement statement = connection.createStatement()) {
|
connection -> {
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
connection.setAutoCommit( true );
|
connection.setAutoCommit( true );
|
||||||
statement.executeUpdate( "ALTER DATABASE CURRENT COLLATE " + originalDBCollation );
|
String dbName;
|
||||||
|
try ( ResultSet rs = statement.executeQuery( "SELECT DB_NAME()" ) ) {
|
||||||
|
rs.next();
|
||||||
|
dbName = rs.getString( 1 );
|
||||||
|
}
|
||||||
|
statement.execute( "USE master" );
|
||||||
|
statement.execute( "ALTER DATABASE " + dbName + " SET SINGLE_USER WITH ROLLBACK IMMEDIATE" );
|
||||||
|
statement.executeUpdate( "ALTER DATABASE " + dbName + " COLLATE " + originalDBCollation );
|
||||||
|
statement.execute( "ALTER DATABASE " + dbName + " SET MULTI_USER WITH ROLLBACK IMMEDIATE" );
|
||||||
|
statement.execute( "USE " + dbName );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
throw new RuntimeException( "Failed to revert back database collation to " + originalDBCollation, e );
|
throw new RuntimeException( "Failed to revert back database collation to " + originalDBCollation, e );
|
||||||
|
@ -72,43 +85,71 @@ public class SQLServerDialectTempTableCollationTest extends BaseCoreFunctionalTe
|
||||||
serviceRegistry.destroy();
|
serviceRegistry.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// The alter database calls could lead to issues with existing connections, so we reset the shared pool here
|
||||||
|
SharedDriverManagerConnectionProviderImpl.getInstance().reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void buildSessionFactory() {
|
protected void buildSessionFactory() {
|
||||||
BootstrapServiceRegistry bootRegistry = buildBootstrapServiceRegistry();
|
BootstrapServiceRegistry bootRegistry = buildBootstrapServiceRegistry();
|
||||||
StandardServiceRegistryImpl serviceRegistry = buildServiceRegistry( bootRegistry, constructConfiguration() );
|
StandardServiceRegistryImpl serviceRegistry = buildServiceRegistry( bootRegistry, constructConfiguration() );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
try ( Connection connection = serviceRegistry.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess().obtainConnection();
|
try {
|
||||||
Statement statement = connection.createStatement() ) {
|
TransactionUtil.doWithJDBC(
|
||||||
|
serviceRegistry,
|
||||||
|
connection -> {
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
connection.setAutoCommit( true );
|
connection.setAutoCommit( true );
|
||||||
try ( ResultSet rs = statement.executeQuery( "SELECT SERVERPROPERTY('collation')" ) ) {
|
try ( ResultSet rs = statement.executeQuery( "SELECT DATABASEPROPERTYEX(DB_NAME(),'collation')" ) ) {
|
||||||
rs.next();
|
rs.next();
|
||||||
String instanceCollation = rs.getString( 1 );
|
String instanceCollation = rs.getString( 1 );
|
||||||
Assert.assertNotEquals( instanceCollation, changedDBCollation );
|
Assert.assertNotEquals( instanceCollation, changedDBCollation );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
log.debug( e.getMessage() );
|
log.debug( e.getMessage() );
|
||||||
}
|
}
|
||||||
try ( Connection connection = serviceRegistry.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess().obtainConnection();
|
try {
|
||||||
Statement statement = connection.createStatement() ) {
|
TransactionUtil.doWithJDBC(
|
||||||
|
serviceRegistry,
|
||||||
|
connection -> {
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
connection.setAutoCommit( true );
|
connection.setAutoCommit( true );
|
||||||
try ( ResultSet rs = statement.executeQuery( "SELECT CONVERT (varchar(256), DATABASEPROPERTYEX(DB_NAME(),'collation'))" ) ) {
|
try ( ResultSet rs = statement.executeQuery( "SELECT CONVERT (varchar(256), DATABASEPROPERTYEX(DB_NAME(),'collation'))" ) ) {
|
||||||
rs.next();
|
rs.next();
|
||||||
originalDBCollation = rs.getString( 1 );
|
originalDBCollation = rs.getString( 1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
log.debug( e.getMessage() );
|
log.debug( e.getMessage() );
|
||||||
}
|
}
|
||||||
try ( Connection connection = serviceRegistry.getService( JdbcServices.class ).getBootstrapJdbcConnectionAccess().obtainConnection();
|
TransactionUtil.doWithJDBC(
|
||||||
Statement statement = connection.createStatement() ) {
|
serviceRegistry,
|
||||||
|
connection -> {
|
||||||
|
try (Statement statement = connection.createStatement()) {
|
||||||
connection.setAutoCommit( true );
|
connection.setAutoCommit( true );
|
||||||
statement.executeUpdate( "ALTER DATABASE CURRENT COLLATE " + changedDBCollation );
|
String dbName;
|
||||||
|
try ( ResultSet rs = statement.executeQuery( "SELECT DB_NAME()" ) ) {
|
||||||
|
rs.next();
|
||||||
|
dbName = rs.getString( 1 );
|
||||||
|
}
|
||||||
|
statement.execute( "USE master" );
|
||||||
|
statement.execute( "ALTER DATABASE " + dbName + " SET SINGLE_USER WITH ROLLBACK IMMEDIATE" );
|
||||||
|
statement.executeUpdate( "ALTER DATABASE " + dbName + " COLLATE " + changedDBCollation );
|
||||||
|
statement.execute( "ALTER DATABASE " + dbName + " SET MULTI_USER WITH ROLLBACK IMMEDIATE" );
|
||||||
|
statement.execute( "USE " + dbName );
|
||||||
collationChanged = true;
|
collationChanged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
catch ( SQLException e ) {
|
catch ( SQLException e ) {
|
||||||
throw new RuntimeException( e );
|
throw new RuntimeException( e );
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,20 @@ public class MultiLineImportFileTest extends BaseCoreFunctionalTestCase {
|
||||||
final String multiLineText = (String) s.createSQLQuery( "SELECT text FROM test_data WHERE id = 2" )
|
final String multiLineText = (String) s.createSQLQuery( "SELECT text FROM test_data WHERE id = 2" )
|
||||||
.uniqueResult();
|
.uniqueResult();
|
||||||
// "Multi-line comment line 1\n-- line 2'\n/* line 3 */"
|
// "Multi-line comment line 1\n-- line 2'\n/* line 3 */"
|
||||||
final String expected = String.format( "Multi-line comment line 1%n-- line 2'%n/* line 3 */" );
|
final String line1 = "Multi-line comment line 1";
|
||||||
|
final String line2 = "-- line 2'";
|
||||||
|
final String line3 = "/* line 3 */";
|
||||||
|
final String lineSeparator;
|
||||||
|
if ( multiLineText.length() < line1.length() + 2 || multiLineText.charAt( line1.length() ) == '\n' ) {
|
||||||
|
lineSeparator = "\n";
|
||||||
|
}
|
||||||
|
else if ( multiLineText.charAt( line1.length() + 1 ) == '\n' ) {
|
||||||
|
lineSeparator = "\r\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lineSeparator = "\r";
|
||||||
|
}
|
||||||
|
final String expected = String.join( lineSeparator, line1, line2, line3 );
|
||||||
assertEquals( "Multi-line string inserted incorrectly", expected, multiLineText );
|
assertEquals( "Multi-line string inserted incorrectly", expected, multiLineText );
|
||||||
|
|
||||||
String empty = (String) s.createSQLQuery( "SELECT text FROM test_data WHERE id = 3" ).uniqueResult();
|
String empty = (String) s.createSQLQuery( "SELECT text FROM test_data WHERE id = 3" ).uniqueResult();
|
||||||
|
|
|
@ -646,6 +646,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-8901" )
|
@TestForIssue( jiraKey = "HHH-8901" )
|
||||||
@RequiresDialectFeature(DialectChecks.NotSupportsEmptyInListCheck.class)
|
@RequiresDialectFeature(DialectChecks.NotSupportsEmptyInListCheck.class)
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't like `x in (null)`")
|
||||||
public void testEmptyInListForDialectsNotSupportsEmptyInList() {
|
public void testEmptyInListForDialectsNotSupportsEmptyInList() {
|
||||||
Session session = openSession();
|
Session session = openSession();
|
||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
|
@ -674,6 +675,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-2851")
|
@TestForIssue( jiraKey = "HHH-2851")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to VARCHAR")
|
||||||
public void testMultipleRefsToSameParam() {
|
public void testMultipleRefsToSameParam() {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
|
@ -1774,6 +1776,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-1830")
|
@TestForIssue(jiraKey = "HHH-1830")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testAggregatedJoinAlias() {
|
public void testAggregatedJoinAlias() {
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
|
|
@ -12,6 +12,7 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
@ -66,6 +67,7 @@ public class CoalesceTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect( jiraKey = "HHH-10463", value = PostgreSQL81Dialect.class)
|
@SkipForDialect( jiraKey = "HHH-10463", value = PostgreSQL81Dialect.class)
|
||||||
@SkipForDialect( jiraKey = "HHH-10463", value = Oracle8iDialect.class)
|
@SkipForDialect( jiraKey = "HHH-10463", value = Oracle8iDialect.class)
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Cannot convert untyped null (assumed to be VARBINARY type) to VARCHAR")
|
||||||
public void HHH_10463_NullInCoalesce() {
|
public void HHH_10463_NullInCoalesce() {
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
Query query = session.createQuery("from Person p where p.name = coalesce(:name, p.name) ");
|
Query query = session.createQuery("from Person p where p.name = coalesce(:name, p.name) ");
|
||||||
|
|
|
@ -16,7 +16,9 @@ import org.hibernate.QueryException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -243,6 +245,7 @@ public class WithClauseTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-11401")
|
@TestForIssue(jiraKey = "HHH-11401")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class,comment = "Derby does not support cast from INTEGER to VARCHAR")
|
||||||
public void testWithClauseAsSubqueryWithKeyAndOtherJoinReference() {
|
public void testWithClauseAsSubqueryWithKeyAndOtherJoinReference() {
|
||||||
TestData data = new TestData();
|
TestData data = new TestData();
|
||||||
data.prepare();
|
data.prepare();
|
||||||
|
|
|
@ -16,7 +16,9 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.ManyToMany;
|
import javax.persistence.ManyToMany;
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -45,6 +47,7 @@ public class ManyToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsCompoundSelectExpression() {
|
public void testSizeAsCompoundSelectExpression() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
@ -73,6 +76,7 @@ public class ManyToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsCtorSelectExpression() {
|
public void testSizeAsCtorSelectExpression() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
@ -102,6 +106,7 @@ public class ManyToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsSelectExpressionWithLeftJoin() {
|
public void testSizeAsSelectExpressionWithLeftJoin() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
@ -131,6 +136,7 @@ public class ManyToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsSelectExpressionWithInnerJoin() {
|
public void testSizeAsSelectExpressionWithInnerJoin() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
@ -156,6 +162,7 @@ public class ManyToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsSelectExpressionOfAliasWithInnerJoin() {
|
public void testSizeAsSelectExpressionOfAliasWithInnerJoin() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
@ -181,6 +188,7 @@ public class ManyToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsSelectExpressionExcludeEmptyCollection() {
|
public void testSizeAsSelectExpressionExcludeEmptyCollection() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
|
|
@ -17,7 +17,9 @@ import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
@ -32,6 +34,7 @@ import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||||
public class OneToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
public class OneToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsSelectExpression() {
|
public void testSizeAsSelectExpression() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
@ -61,6 +64,7 @@ public class OneToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsSelectExpressionWithLeftJoin() {
|
public void testSizeAsSelectExpressionWithLeftJoin() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
@ -90,6 +94,7 @@ public class OneToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsSelectExpressionWithInnerJoin() {
|
public void testSizeAsSelectExpressionWithInnerJoin() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
@ -115,6 +120,7 @@ public class OneToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsSelectExpressionOfAliasWithInnerJoin() {
|
public void testSizeAsSelectExpressionOfAliasWithInnerJoin() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
@ -140,6 +146,7 @@ public class OneToManySizeTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby doesn't see that the subquery is functionally dependent")
|
||||||
public void testSizeAsSelectExpressionExcludeEmptyCollection() {
|
public void testSizeAsSelectExpressionExcludeEmptyCollection() {
|
||||||
doInHibernate(
|
doInHibernate(
|
||||||
this::sessionFactory,
|
this::sessionFactory,
|
||||||
|
|
|
@ -78,6 +78,7 @@ public class HiLoSequenceMismatchStrategyTest extends BaseCoreFunctionalTestCase
|
||||||
for ( String createSequenceStatement : createSequenceStatements ) {
|
for ( String createSequenceStatement : createSequenceStatements ) {
|
||||||
statement.execute( createSequenceStatement );
|
statement.execute( createSequenceStatement );
|
||||||
}
|
}
|
||||||
|
connection.commit();
|
||||||
}
|
}
|
||||||
catch (SQLException e) {
|
catch (SQLException e) {
|
||||||
fail( e.getMessage() );
|
fail( e.getMessage() );
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.inheritance;
|
package org.hibernate.test.inheritance;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.ConstraintMode;
|
import javax.persistence.ConstraintMode;
|
||||||
|
@ -85,6 +86,7 @@ public class TransientOverrideAsPersistentJoined extends BaseNonConfigCoreFuncti
|
||||||
final List<Employee> employees = session.createQuery( "from Employee", Employee.class )
|
final List<Employee> employees = session.createQuery( "from Employee", Employee.class )
|
||||||
.getResultList();
|
.getResultList();
|
||||||
assertEquals( 2, employees.size() );
|
assertEquals( 2, employees.size() );
|
||||||
|
employees.sort( Comparator.comparing( Employee::getName ) );
|
||||||
assertTrue( Editor.class.isInstance( employees.get( 0 ) ) );
|
assertTrue( Editor.class.isInstance( employees.get( 0 ) ) );
|
||||||
assertTrue( Writer.class.isInstance( employees.get( 1 ) ) );
|
assertTrue( Writer.class.isInstance( employees.get( 1 ) ) );
|
||||||
final Editor editor = (Editor) employees.get( 0 );
|
final Editor editor = (Editor) employees.get( 0 );
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.inheritance;
|
package org.hibernate.test.inheritance;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.ConstraintMode;
|
import javax.persistence.ConstraintMode;
|
||||||
|
@ -84,6 +85,7 @@ public class TransientOverrideAsPersistentTablePerClass extends BaseNonConfigCor
|
||||||
final List<Employee> employees = session.createQuery( "from Employee", Employee.class )
|
final List<Employee> employees = session.createQuery( "from Employee", Employee.class )
|
||||||
.getResultList();
|
.getResultList();
|
||||||
assertEquals( 2, employees.size() );
|
assertEquals( 2, employees.size() );
|
||||||
|
employees.sort( Comparator.comparing( Employee::getName ) );
|
||||||
assertTrue( Editor.class.isInstance( employees.get( 0 ) ) );
|
assertTrue( Editor.class.isInstance( employees.get( 0 ) ) );
|
||||||
assertTrue( Writer.class.isInstance( employees.get( 1 ) ) );
|
assertTrue( Writer.class.isInstance( employees.get( 1 ) ) );
|
||||||
final Editor editor = (Editor) employees.get( 0 );
|
final Editor editor = (Editor) employees.get( 0 );
|
||||||
|
|
|
@ -16,10 +16,12 @@ import java.sql.Statement;
|
||||||
|
|
||||||
import org.hibernate.JDBCException;
|
import org.hibernate.JDBCException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.engine.spi.SessionImplementor;
|
import org.hibernate.engine.spi.SessionImplementor;
|
||||||
import org.hibernate.resource.jdbc.ResourceRegistry;
|
import org.hibernate.resource.jdbc.ResourceRegistry;
|
||||||
|
|
||||||
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@ -50,6 +52,7 @@ public class BasicConnectionTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SkipForDialect(value = DerbyDialect.class,comment = "Derby can't drop tables that are still referred to from open ResultSets")
|
||||||
public void testBasicJdbcUsage() throws JDBCException {
|
public void testBasicJdbcUsage() throws JDBCException {
|
||||||
Session session = openSession();
|
Session session = openSession();
|
||||||
SessionImplementor sessionImpl = (SessionImplementor) session;
|
SessionImplementor sessionImpl = (SessionImplementor) session;
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class ProxyReferenceEqualityTest extends BaseCoreFunctionalTestCase {
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "A")
|
||||||
public static class A {
|
public static class A {
|
||||||
@Id
|
@Id
|
||||||
Long id;
|
Long id;
|
||||||
|
@ -72,7 +72,7 @@ public class ProxyReferenceEqualityTest extends BaseCoreFunctionalTestCase {
|
||||||
B b;
|
B b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity(name = "B")
|
||||||
public static class B {
|
public static class B {
|
||||||
@Id
|
@Id
|
||||||
Long id;
|
Long id;
|
||||||
|
|
|
@ -61,16 +61,15 @@ public class TableGeneratorQuotingTest extends BaseUnitTestCase {
|
||||||
final Metadata metadata = new MetadataSources( serviceRegistry ).addAnnotatedClass( TestEntity.class ).buildMetadata();
|
final Metadata metadata = new MetadataSources( serviceRegistry ).addAnnotatedClass( TestEntity.class ).buildMetadata();
|
||||||
|
|
||||||
final ConnectionProvider connectionProvider = serviceRegistry.getService( ConnectionProvider.class );
|
final ConnectionProvider connectionProvider = serviceRegistry.getService( ConnectionProvider.class );
|
||||||
final GenerationTarget target = new GenerationTargetToDatabase(
|
|
||||||
new DdlTransactionIsolatorTestingImpl(
|
final DdlTransactionIsolatorTestingImpl ddlTransactionIsolator = new DdlTransactionIsolatorTestingImpl(
|
||||||
serviceRegistry,
|
serviceRegistry,
|
||||||
new JdbcEnvironmentInitiator.ConnectionProviderJdbcConnectionAccess( connectionProvider )
|
new JdbcEnvironmentInitiator.ConnectionProviderJdbcConnectionAccess( connectionProvider )
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
new SchemaCreatorImpl( serviceRegistry ).doCreation( metadata, false, target );
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
final GenerationTarget target = new GenerationTargetToDatabase( ddlTransactionIsolator, false );
|
||||||
|
try {
|
||||||
|
new SchemaCreatorImpl( serviceRegistry ).doCreation( metadata, false, target );
|
||||||
new SchemaValidator().validate( metadata );
|
new SchemaValidator().validate( metadata );
|
||||||
}
|
}
|
||||||
catch (HibernateException e) {
|
catch (HibernateException e) {
|
||||||
|
@ -80,6 +79,10 @@ public class TableGeneratorQuotingTest extends BaseUnitTestCase {
|
||||||
new SchemaDropperImpl( serviceRegistry ).doDrop( metadata, false, target );
|
new SchemaDropperImpl( serviceRegistry ).doDrop( metadata, false, target );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
ddlTransactionIsolator.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "test_entity")
|
@Table(name = "test_entity")
|
||||||
|
|
|
@ -51,53 +51,77 @@ public class TestExtraPhysicalTableTypes {
|
||||||
@Test
|
@Test
|
||||||
public void testAddOneExtraPhysicalTableType() throws Exception {
|
public void testAddOneExtraPhysicalTableType() throws Exception {
|
||||||
buildMetadata( "BASE TABLE" );
|
buildMetadata( "BASE TABLE" );
|
||||||
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest();
|
DdlTransactionIsolator ddlTransactionIsolator = buildDdlTransactionIsolator();
|
||||||
|
try {
|
||||||
|
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest(
|
||||||
|
ddlTransactionIsolator
|
||||||
|
);
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "BASE TABLE" ), is( true ) );
|
assertThat( informationExtractor.isPhysicalTableType( "BASE TABLE" ), is( true ) );
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "TABLE" ), is( true ) );
|
assertThat( informationExtractor.isPhysicalTableType( "TABLE" ), is( true ) );
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
ddlTransactionIsolator.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddingMultipleExtraPhysicalTableTypes() throws Exception {
|
public void testAddingMultipleExtraPhysicalTableTypes() throws Exception {
|
||||||
buildMetadata( "BASE, BASE TABLE" );
|
buildMetadata( "BASE, BASE TABLE" );
|
||||||
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest();
|
DdlTransactionIsolator ddlTransactionIsolator = buildDdlTransactionIsolator();
|
||||||
|
try {
|
||||||
|
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest(
|
||||||
|
ddlTransactionIsolator
|
||||||
|
);
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "BASE TABLE" ), is( true ) );
|
assertThat( informationExtractor.isPhysicalTableType( "BASE TABLE" ), is( true ) );
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "BASE" ), is( true ) );
|
assertThat( informationExtractor.isPhysicalTableType( "BASE" ), is( true ) );
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "TABLE" ), is( true ) );
|
assertThat( informationExtractor.isPhysicalTableType( "TABLE" ), is( true ) );
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "TABLE 1" ), is( false ) );
|
assertThat( informationExtractor.isPhysicalTableType( "TABLE 1" ), is( false ) );
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
ddlTransactionIsolator.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtraPhysicalTableTypesPropertyEmptyStringValue() throws Exception {
|
public void testExtraPhysicalTableTypesPropertyEmptyStringValue() throws Exception {
|
||||||
buildMetadata( " " );
|
buildMetadata( " " );
|
||||||
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest();
|
DdlTransactionIsolator ddlTransactionIsolator = buildDdlTransactionIsolator();
|
||||||
|
try {
|
||||||
|
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest(
|
||||||
|
ddlTransactionIsolator
|
||||||
|
);
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "BASE TABLE" ), is( false ) );
|
assertThat( informationExtractor.isPhysicalTableType( "BASE TABLE" ), is( false ) );
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "TABLE" ), is( true ) );
|
assertThat( informationExtractor.isPhysicalTableType( "TABLE" ), is( true ) );
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
ddlTransactionIsolator.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoExtraPhysicalTabeTypesProperty() throws Exception {
|
public void testNoExtraPhysicalTabeTypesProperty() throws Exception {
|
||||||
buildMetadata( null );
|
buildMetadata( null );
|
||||||
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest();
|
DdlTransactionIsolator ddlTransactionIsolator = buildDdlTransactionIsolator();
|
||||||
|
try {
|
||||||
|
InformationExtractorJdbcDatabaseMetaDataImplTest informationExtractor = buildInformationExtractorJdbcDatabaseMetaDataImplTest(
|
||||||
|
ddlTransactionIsolator
|
||||||
|
);
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "BASE TABLE" ), is( false ) );
|
assertThat( informationExtractor.isPhysicalTableType( "BASE TABLE" ), is( false ) );
|
||||||
assertThat( informationExtractor.isPhysicalTableType( "TABLE" ), is( true ) );
|
assertThat( informationExtractor.isPhysicalTableType( "TABLE" ), is( true ) );
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
ddlTransactionIsolator.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private InformationExtractorJdbcDatabaseMetaDataImplTest buildInformationExtractorJdbcDatabaseMetaDataImplTest()
|
private InformationExtractorJdbcDatabaseMetaDataImplTest buildInformationExtractorJdbcDatabaseMetaDataImplTest(DdlTransactionIsolator ddlTransactionIsolator)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
Database database = metadata.getDatabase();
|
Database database = metadata.getDatabase();
|
||||||
|
|
||||||
final ConnectionProvider connectionProvider = ssr.getService( ConnectionProvider.class );
|
|
||||||
DatabaseInformation dbInfo = new DatabaseInformationImpl(
|
DatabaseInformation dbInfo = new DatabaseInformationImpl(
|
||||||
ssr,
|
ssr,
|
||||||
database.getJdbcEnvironment(),
|
database.getJdbcEnvironment(),
|
||||||
new DdlTransactionIsolatorTestingImpl( ssr,
|
ddlTransactionIsolator,
|
||||||
new JdbcEnvironmentInitiator.ConnectionProviderJdbcConnectionAccess(
|
|
||||||
connectionProvider )
|
|
||||||
),
|
|
||||||
database.getDefaultNamespace().getName()
|
database.getDefaultNamespace().getName()
|
||||||
);
|
);
|
||||||
ExtractionContextImpl extractionContext = new ExtractionContextImpl(
|
ExtractionContextImpl extractionContext = new ExtractionContextImpl(
|
||||||
|
@ -113,6 +137,14 @@ public class TestExtraPhysicalTableTypes {
|
||||||
extractionContext );
|
extractionContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DdlTransactionIsolator buildDdlTransactionIsolator() {
|
||||||
|
final ConnectionProvider connectionProvider = ssr.getService( ConnectionProvider.class );
|
||||||
|
return new DdlTransactionIsolatorTestingImpl(
|
||||||
|
ssr,
|
||||||
|
new JdbcEnvironmentInitiator.ConnectionProviderJdbcConnectionAccess( connectionProvider )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private void buildMetadata(String extraPhysicalTableTypes) {
|
private void buildMetadata(String extraPhysicalTableTypes) {
|
||||||
if ( extraPhysicalTableTypes == null ) {
|
if ( extraPhysicalTableTypes == null ) {
|
||||||
ssr = new StandardServiceRegistryBuilder().build();
|
ssr = new StandardServiceRegistryBuilder().build();
|
||||||
|
@ -128,8 +160,16 @@ public class TestExtraPhysicalTableTypes {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InformationExtractorJdbcDatabaseMetaDataImplTest extends InformationExtractorJdbcDatabaseMetaDataImpl {
|
public class InformationExtractorJdbcDatabaseMetaDataImplTest extends InformationExtractorJdbcDatabaseMetaDataImpl {
|
||||||
|
|
||||||
|
private final ExtractionContext extractionContext;
|
||||||
|
|
||||||
public InformationExtractorJdbcDatabaseMetaDataImplTest(ExtractionContext extractionContext) {
|
public InformationExtractorJdbcDatabaseMetaDataImplTest(ExtractionContext extractionContext) {
|
||||||
super( extractionContext );
|
super( extractionContext );
|
||||||
|
this.extractionContext = extractionContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExtractionContext getExtractionContext() {
|
||||||
|
return extractionContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPhysicalTableType(String tableType) {
|
public boolean isPhysicalTableType(String tableType) {
|
||||||
|
|
|
@ -98,8 +98,15 @@ public class PostgreSQLMultipleSchemaSequenceTest extends BaseUnitTestCase {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String existingUrl = (String) Environment.getProperties().get( AvailableSettings.URL );
|
||||||
|
if ( existingUrl.indexOf( '?' ) == -1 ) {
|
||||||
|
existingUrl += "?";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
existingUrl += "&";
|
||||||
|
}
|
||||||
StandardServiceRegistry ssr2 = new StandardServiceRegistryBuilder()
|
StandardServiceRegistry ssr2 = new StandardServiceRegistryBuilder()
|
||||||
.applySetting( AvailableSettings.URL, Environment.getProperties().get(AvailableSettings.URL) + "?currentSchema=" + extraSchemaName )
|
.applySetting( AvailableSettings.URL, existingUrl + "currentSchema=" + extraSchemaName )
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import javax.persistence.Id;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.tool.schema.spi.SchemaManagementException;
|
import org.hibernate.tool.schema.spi.SchemaManagementException;
|
||||||
|
@ -25,6 +26,7 @@ import org.junit.Test;
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@SkipForDialect(value = DB2Dialect.class, comment = "DB2 is far more resistant to the reserved keyword usage. See HHH-12832.")
|
@SkipForDialect(value = DB2Dialect.class, comment = "DB2 is far more resistant to the reserved keyword usage. See HHH-12832.")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby is far more resistant to the reserved keyword usage.")
|
||||||
public class SchemaMigratorHaltOnErrorTest extends BaseEntityManagerFunctionalTestCase {
|
public class SchemaMigratorHaltOnErrorTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,6 +23,8 @@ import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
import org.hibernate.testing.SkipForDialect;
|
import org.hibernate.testing.SkipForDialect;
|
||||||
import org.hibernate.testing.junit4.CustomRunner;
|
import org.hibernate.testing.junit4.CustomRunner;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
import org.hibernate.tool.hbm2ddl.SchemaUpdate;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
import org.hibernate.tool.schema.spi.SchemaManagementException;
|
import org.hibernate.tool.schema.spi.SchemaManagementException;
|
||||||
|
@ -36,6 +38,7 @@ import org.junit.runner.RunWith;
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
@SkipForDialect(value = DB2Dialect.class, comment = "DB2 is far more resistant to the reserved keyword usage. See HHH-12832.")
|
@SkipForDialect(value = DB2Dialect.class, comment = "DB2 is far more resistant to the reserved keyword usage. See HHH-12832.")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby is far more resistant to the reserved keyword usage.")
|
||||||
@RunWith(CustomRunner.class)
|
@RunWith(CustomRunner.class)
|
||||||
public class SchemaUpdateHaltOnErrorTest {
|
public class SchemaUpdateHaltOnErrorTest {
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.EnumSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.Type;
|
import org.hibernate.annotations.Type;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
|
@ -156,6 +157,7 @@ public class LongVarcharValidationTest implements ExecutionOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity(name = "Translation")
|
@Entity(name = "Translation")
|
||||||
|
@Table(name = "translation_tbl")
|
||||||
public static class Translation {
|
public static class Translation {
|
||||||
@Id
|
@Id
|
||||||
public Integer id;
|
public Integer id;
|
||||||
|
|
|
@ -13,9 +13,7 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.dialect.Dialect;
|
|
||||||
import org.hibernate.dialect.MySQL5Dialect;
|
import org.hibernate.dialect.MySQL5Dialect;
|
||||||
import org.hibernate.dialect.MySQL8Dialect;
|
|
||||||
|
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
|
|
@ -138,12 +138,12 @@ abstract class AbstractJavaTimeTypeTest<T, E> extends BaseCoreFunctionalTestCase
|
||||||
} );
|
} );
|
||||||
inTransaction( session -> {
|
inTransaction( session -> {
|
||||||
session.doWork( connection -> {
|
session.doWork( connection -> {
|
||||||
final PreparedStatement statement = connection.prepareStatement(
|
try (PreparedStatement statement = connection.prepareStatement(
|
||||||
"SELECT " + PROPERTY_COLUMN_NAME + " FROM " + ENTITY_NAME + " WHERE " + ID_COLUMN_NAME + " = ?"
|
"SELECT " + PROPERTY_COLUMN_NAME + " FROM " + ENTITY_NAME + " WHERE " + ID_COLUMN_NAME + " = ?"
|
||||||
);
|
)) {
|
||||||
statement.setInt( 1, 1 );
|
statement.setInt( 1, 1 );
|
||||||
statement.execute();
|
statement.execute();
|
||||||
final ResultSet resultSet = statement.getResultSet();
|
try (ResultSet resultSet = statement.getResultSet()) {
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
Object nativeRead = getActualJdbcValue( resultSet, 1 );
|
Object nativeRead = getActualJdbcValue( resultSet, 1 );
|
||||||
assertEquals(
|
assertEquals(
|
||||||
|
@ -151,6 +151,8 @@ abstract class AbstractJavaTimeTypeTest<T, E> extends BaseCoreFunctionalTestCase
|
||||||
getExpectedJdbcValueAfterHibernateWrite(),
|
getExpectedJdbcValueAfterHibernateWrite(),
|
||||||
nativeRead
|
nativeRead
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
@ -164,13 +166,14 @@ abstract class AbstractJavaTimeTypeTest<T, E> extends BaseCoreFunctionalTestCase
|
||||||
withDefaultTimeZone( () -> {
|
withDefaultTimeZone( () -> {
|
||||||
inTransaction( session -> {
|
inTransaction( session -> {
|
||||||
session.doWork( connection -> {
|
session.doWork( connection -> {
|
||||||
final PreparedStatement statement = connection.prepareStatement(
|
try (PreparedStatement statement = connection.prepareStatement(
|
||||||
"INSERT INTO " + ENTITY_NAME + " (" + ID_COLUMN_NAME + ", " + PROPERTY_COLUMN_NAME + ") "
|
"INSERT INTO " + ENTITY_NAME + " (" + ID_COLUMN_NAME + ", " + PROPERTY_COLUMN_NAME + ") "
|
||||||
+ " VALUES ( ? , ? )"
|
+ " VALUES ( ? , ? )"
|
||||||
);
|
)) {
|
||||||
statement.setInt( 1, 1 );
|
statement.setInt( 1, 1 );
|
||||||
setJdbcValueForNonHibernateWrite( statement, 2 );
|
setJdbcValueForNonHibernateWrite( statement, 2 );
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
inTransaction( session -> {
|
inTransaction( session -> {
|
||||||
|
|
|
@ -14,6 +14,8 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
|
@ -39,6 +41,9 @@ public class PreparedStatementSpyConnectionProvider extends ConnectionProviderDe
|
||||||
.defaultAnswer( org.mockito.Answers.CALLS_REAL_METHODS );
|
.defaultAnswer( org.mockito.Answers.CALLS_REAL_METHODS );
|
||||||
private static final MockSettings VERIFIEABLE_MOCK_SETTINGS = Mockito.withSettings()
|
private static final MockSettings VERIFIEABLE_MOCK_SETTINGS = Mockito.withSettings()
|
||||||
.defaultAnswer( org.mockito.Answers.CALLS_REAL_METHODS );
|
.defaultAnswer( org.mockito.Answers.CALLS_REAL_METHODS );
|
||||||
|
// We must keep around the mocked connections, otherwise they are garbage collected and trigger finalizers
|
||||||
|
// Since we use CALLS_REAL_METHODS this might close underlying IO resources which makes other objects unusable
|
||||||
|
private static final Queue<Object> MOCKS = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
private final Map<PreparedStatement, String> preparedStatementMap = new LinkedHashMap<>();
|
private final Map<PreparedStatement, String> preparedStatementMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
@ -75,6 +80,7 @@ public class PreparedStatementSpyConnectionProvider extends ConnectionProviderDe
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
Connection connection = instrumentConnection( actualConnection() );
|
Connection connection = instrumentConnection( actualConnection() );
|
||||||
|
MOCKS.add( connection );
|
||||||
acquiredConnections.add( connection );
|
acquiredConnections.add( connection );
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +89,7 @@ public class PreparedStatementSpyConnectionProvider extends ConnectionProviderDe
|
||||||
public void closeConnection(Connection conn) throws SQLException {
|
public void closeConnection(Connection conn) throws SQLException {
|
||||||
acquiredConnections.remove( conn );
|
acquiredConnections.remove( conn );
|
||||||
releasedConnections.add( conn );
|
releasedConnections.add( conn );
|
||||||
super.closeConnection( conn );
|
super.closeConnection( (Connection) MockUtil.getMockSettings( conn ).getSpiedInstance() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<property name="dirty" type="boolean" />
|
<property name="dirty" type="boolean" />
|
||||||
<property name="decodeAttempts" type="java.lang.Integer" column="decode_attempts"/>
|
<property name="decodeAttempts" type="java.lang.Integer" column="decode_attempts"/>
|
||||||
|
|
||||||
<property name="year" type="java.lang.Integer" column="year" />
|
<property name="year" type="java.lang.Integer" column="year_value" />
|
||||||
<property name="msrp" type="java.lang.Double" column="msrp_value" />
|
<property name="msrp" type="java.lang.Double" column="msrp_value" />
|
||||||
<property name="residualValue" type="java.lang.Double" column="residual_value" />
|
<property name="residualValue" type="java.lang.Double" column="residual_value" />
|
||||||
<property name="invoicePrice" type="java.lang.Double" column="invoice_price" />
|
<property name="invoicePrice" type="java.lang.Double" column="invoice_price" />
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class TestHelper {
|
||||||
final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder()
|
final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder()
|
||||||
.configure( "hibernate-config/hibernate.cfg.xml" )
|
.configure( "hibernate-config/hibernate.cfg.xml" )
|
||||||
.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" )
|
.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" )
|
||||||
.applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE )
|
.applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP )
|
||||||
.applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
.applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
||||||
|
|
||||||
if ( H2Dialect.class.equals( Dialect.getDialect().getClass() ) ) {
|
if ( H2Dialect.class.equals( Dialect.getDialect().getClass() ) ) {
|
||||||
|
|
|
@ -16,6 +16,8 @@ import javax.persistence.Id;
|
||||||
import javax.persistence.Lob;
|
import javax.persistence.Lob;
|
||||||
|
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.envers.Audited;
|
import org.hibernate.envers.Audited;
|
||||||
|
@ -37,6 +39,8 @@ import static org.junit.Assert.assertEquals;
|
||||||
@SkipForDialect(Oracle8iDialect.class)
|
@SkipForDialect(Oracle8iDialect.class)
|
||||||
@SkipForDialect(value = PostgreSQL81Dialect.class, jiraKey = "HHH-11477", comment = "@Lob field in HQL predicate fails with error about text = bigint")
|
@SkipForDialect(value = PostgreSQL81Dialect.class, jiraKey = "HHH-11477", comment = "@Lob field in HQL predicate fails with error about text = bigint")
|
||||||
@SkipForDialect(value = AbstractHANADialect.class, comment = "HANA doesn't support comparing LOBs with the = operator")
|
@SkipForDialect(value = AbstractHANADialect.class, comment = "HANA doesn't support comparing LOBs with the = operator")
|
||||||
|
@SkipForDialect(value = DB2Dialect.class, comment = "DB2 jdbc driver doesn't support setNString")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby jdbc driver doesn't support setNString")
|
||||||
public class StringMapLobTest extends BaseEnversJPAFunctionalTestCase {
|
public class StringMapLobTest extends BaseEnversJPAFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
|
|
@ -17,6 +17,8 @@ import javax.persistence.Lob;
|
||||||
|
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
import org.hibernate.dialect.AbstractHANADialect;
|
import org.hibernate.dialect.AbstractHANADialect;
|
||||||
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Oracle8iDialect;
|
import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.dialect.SybaseDialect;
|
import org.hibernate.dialect.SybaseDialect;
|
||||||
|
@ -40,6 +42,8 @@ import static org.junit.Assert.assertEquals;
|
||||||
@SkipForDialect(value = PostgreSQL81Dialect.class, jiraKey = "HHH-11477", comment = "@Lob field in HQL predicate fails with error about text = bigint")
|
@SkipForDialect(value = PostgreSQL81Dialect.class, jiraKey = "HHH-11477", comment = "@Lob field in HQL predicate fails with error about text = bigint")
|
||||||
@SkipForDialect(value = AbstractHANADialect.class, comment = "HANA doesn't support comparing LOBs with the = operator")
|
@SkipForDialect(value = AbstractHANADialect.class, comment = "HANA doesn't support comparing LOBs with the = operator")
|
||||||
@SkipForDialect(value = SybaseDialect.class, comment = "Sybase doesn't support comparing LOBs with the = operator")
|
@SkipForDialect(value = SybaseDialect.class, comment = "Sybase doesn't support comparing LOBs with the = operator")
|
||||||
|
@SkipForDialect(value = DB2Dialect.class, comment = "DB2 jdbc driver doesn't support setNString")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby jdbc driver doesn't support setNString")
|
||||||
public class StringMapNationalizedLobTest extends BaseEnversJPAFunctionalTestCase {
|
public class StringMapNationalizedLobTest extends BaseEnversJPAFunctionalTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.dialect.Oracle8iDialect;
|
||||||
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase;
|
||||||
import org.hibernate.envers.test.entities.StrTestEntity;
|
import org.hibernate.envers.test.entities.StrTestEntity;
|
||||||
|
|
||||||
|
import org.hibernate.testing.BeforeClassOnce;
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
@ -45,7 +46,7 @@ public class OrderSequenceGenerationTest extends BaseEnversJPAFunctionalTestCase
|
||||||
return new Class<?>[] { StrTestEntity.class };
|
return new Class<?>[] { StrTestEntity.class };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Override
|
||||||
public void buildEntityManagerFactory() throws Exception {
|
public void buildEntityManagerFactory() throws Exception {
|
||||||
createSchema = File.createTempFile( "create_schema", ".sql" );
|
createSchema = File.createTempFile( "create_schema", ".sql" );
|
||||||
dropSchema = File.createTempFile( "drop_schema", ".sql" );
|
dropSchema = File.createTempFile( "drop_schema", ".sql" );
|
||||||
|
@ -58,7 +59,7 @@ public class OrderSequenceGenerationTest extends BaseEnversJPAFunctionalTestCase
|
||||||
options.put( AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET, createSchema.toPath() );
|
options.put( AvailableSettings.HBM2DDL_SCRIPTS_CREATE_TARGET, createSchema.toPath() );
|
||||||
options.put( AvailableSettings.HBM2DDL_SCRIPTS_DROP_TARGET, dropSchema.toPath() );
|
options.put( AvailableSettings.HBM2DDL_SCRIPTS_DROP_TARGET, dropSchema.toPath() );
|
||||||
options.put( AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "drop-and-create" );
|
options.put( AvailableSettings.HBM2DDL_SCRIPTS_ACTION, "drop-and-create" );
|
||||||
options.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "drop-and-create" );
|
options.put( AvailableSettings.HBM2DDL_DATABASE_ACTION, "create-drop" );
|
||||||
options.put( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
options.put( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
|
|
||||||
|
@ -32,6 +34,9 @@ import org.mockito.internal.util.MockUtil;
|
||||||
public class PreparedStatementSpyConnectionProvider
|
public class PreparedStatementSpyConnectionProvider
|
||||||
extends ConnectionProviderDelegate {
|
extends ConnectionProviderDelegate {
|
||||||
|
|
||||||
|
// We must keep around the mocked connections, otherwise the are garbage collected and trigger finalizers
|
||||||
|
// Since we use CALLS_REAL_METHODS this might close underlying IO resources which make other objects unusable
|
||||||
|
private static final Queue<Object> MOCKS = new LinkedBlockingQueue<>();
|
||||||
private final Map<PreparedStatement, String> preparedStatementMap = new LinkedHashMap<>();
|
private final Map<PreparedStatement, String> preparedStatementMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
private final List<Connection> acquiredConnections = new ArrayList<>( );
|
private final List<Connection> acquiredConnections = new ArrayList<>( );
|
||||||
|
@ -47,6 +52,7 @@ public class PreparedStatementSpyConnectionProvider
|
||||||
@Override
|
@Override
|
||||||
public Connection getConnection() throws SQLException {
|
public Connection getConnection() throws SQLException {
|
||||||
Connection connection = spy( actualConnection() );
|
Connection connection = spy( actualConnection() );
|
||||||
|
MOCKS.add( connection );
|
||||||
acquiredConnections.add( connection );
|
acquiredConnections.add( connection );
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +61,7 @@ public class PreparedStatementSpyConnectionProvider
|
||||||
public void closeConnection(Connection conn) throws SQLException {
|
public void closeConnection(Connection conn) throws SQLException {
|
||||||
acquiredConnections.remove( conn );
|
acquiredConnections.remove( conn );
|
||||||
releasedConnections.add( conn );
|
releasedConnections.add( conn );
|
||||||
super.closeConnection( conn );
|
super.closeConnection( (Connection) MockUtil.getMockSettings( conn ).getSpiedInstance() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.hibernate.boot.MetadataSources;
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.dialect.CockroachDB192Dialect;
|
import org.hibernate.dialect.CockroachDB192Dialect;
|
||||||
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
@ -58,7 +59,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
serviceRegistry = ssrb
|
serviceRegistry = ssrb
|
||||||
.configure( "hibernate-config/hibernate.cfg.xml" )
|
.configure( "hibernate-config/hibernate.cfg.xml" )
|
||||||
.applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE )
|
.applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP )
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final MetadataSources metadataSources = new MetadataSources( serviceRegistry );
|
final MetadataSources metadataSources = new MetadataSources( serviceRegistry );
|
||||||
|
@ -87,6 +88,7 @@ public class RefreshUpdatedDataTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(value = CockroachDB192Dialect.class, comment = "does not support nested transactions")
|
@SkipForDialect(value = CockroachDB192Dialect.class, comment = "does not support nested transactions")
|
||||||
|
@SkipForDialect(value = DerbyDialect.class, comment = "Derby does not support nested transactions")
|
||||||
public void testUpdateAndFlushThenRefresh() {
|
public void testUpdateAndFlushThenRefresh() {
|
||||||
final String BEFORE = "before";
|
final String BEFORE = "before";
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class TestHelper {
|
||||||
final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder()
|
final StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder()
|
||||||
.configure( "hibernate-config/hibernate.cfg.xml" )
|
.configure( "hibernate-config/hibernate.cfg.xml" )
|
||||||
.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" )
|
.applySetting( AvailableSettings.GENERATE_STATISTICS, "true" )
|
||||||
.applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE )
|
.applySetting( AvailableSettings.HBM2DDL_DATABASE_ACTION, Action.CREATE_DROP )
|
||||||
.applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
.applySetting( AvailableSettings.HBM2DDL_AUTO, "create-drop" );
|
||||||
|
|
||||||
if ( H2Dialect.class.equals( Dialect.getDialect().getClass() ) ) {
|
if ( H2Dialect.class.equals( Dialect.getDialect().getClass() ) ) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.dialect.SybaseDialect;
|
import org.hibernate.dialect.SybaseDialect;
|
||||||
|
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container class for different implementation of the {@link DialectCheck} interface.
|
* Container class for different implementation of the {@link DialectCheck} interface.
|
||||||
|
@ -291,4 +292,10 @@ abstract public class DialectChecks {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class SupportsGlobalTemporaryTables implements DialectCheck {
|
||||||
|
public boolean isMatch(Dialect dialect) {
|
||||||
|
return dialect.getDefaultMultiTableBulkIdStrategy() instanceof GlobalTemporaryTableBulkIdStrategy;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,9 @@ import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||||
|
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
|
import org.hibernate.service.ServiceRegistry;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
|
||||||
|
@ -155,6 +157,24 @@ public class TransactionUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDBC transaction function
|
||||||
|
*
|
||||||
|
* @param <T> function result
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface JDBCTransactionFunction<T> {
|
||||||
|
T accept(Connection connection) throws SQLException;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JDBC transaction function without return value
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface JDBCTransactionVoidFunction {
|
||||||
|
void accept(Connection connection) throws SQLException;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute function in a JPA transaction
|
* Execute function in a JPA transaction
|
||||||
*
|
*
|
||||||
|
@ -692,4 +712,40 @@ public class TransactionUtil {
|
||||||
public static void doInAutoCommit(String... statements) {
|
public static void doInAutoCommit(String... statements) {
|
||||||
doInAutoCommit( null, statements );
|
doInAutoCommit( null, statements );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void doWithJDBC(ServiceRegistry serviceRegistry, JDBCTransactionVoidFunction function) throws SQLException {
|
||||||
|
final JdbcConnectionAccess connectionAccess = serviceRegistry.getService( JdbcServices.class )
|
||||||
|
.getBootstrapJdbcConnectionAccess();
|
||||||
|
Connection connection = connectionAccess.obtainConnection();
|
||||||
|
try {
|
||||||
|
function.accept( connection );
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if ( connection != null ) {
|
||||||
|
try {
|
||||||
|
connectionAccess.releaseConnection( connection );
|
||||||
|
}
|
||||||
|
catch (SQLException ignore) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T doWithJDBC(ServiceRegistry serviceRegistry, JDBCTransactionFunction<T> function) throws SQLException {
|
||||||
|
final JdbcConnectionAccess connectionAccess = serviceRegistry.getService( JdbcServices.class )
|
||||||
|
.getBootstrapJdbcConnectionAccess();
|
||||||
|
Connection connection = connectionAccess.obtainConnection();
|
||||||
|
try {
|
||||||
|
return function.accept( connection );
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if ( connection != null ) {
|
||||||
|
try {
|
||||||
|
connectionAccess.releaseConnection( connection );
|
||||||
|
}
|
||||||
|
catch (SQLException ignore) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue