HHH-17090 - Remove support for Oracle versions older than 19

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2023-10-12 00:09:22 +02:00 committed by Christian Beikov
parent ec639cd1f7
commit ed84eddcb6
13 changed files with 67 additions and 151 deletions

View File

@ -617,71 +617,6 @@ grant all privileges to hibernate_orm_test;
EOF\""
}
oracle_setup_old() {
HEALTHSTATUS=
until [ "$HEALTHSTATUS" == "healthy" ];
do
echo "Waiting for Oracle to start..."
sleep 5;
# On WSL, health-checks intervals don't work for Podman, so run them manually
if command -v podman > /dev/null; then
$PRIVILEGED_CLI $CONTAINER_CLI healthcheck run oracle > /dev/null
fi
HEALTHSTATUS="`$PRIVILEGED_CLI $CONTAINER_CLI inspect -f $HEALTCHECK_PATH oracle`"
HEALTHSTATUS=${HEALTHSTATUS##+( )} #Remove longest matching series of spaces from the front
HEALTHSTATUS=${HEALTHSTATUS%%+( )} #Remove longest matching series of spaces from the back
done
# We increase file sizes to avoid online resizes as that requires lots of CPU which is restricted in XE
$PRIVILEGED_CLI $CONTAINER_CLI exec oracle bash -c "source /home/oracle/.bashrc; bash -c \"
cat <<EOF | \$ORACLE_HOME/bin/sqlplus / as sysdba
alter database tempfile '\$ORACLE_BASE/oradata/XE/temp.dbf' resize 400M;
alter database datafile '\$ORACLE_BASE/oradata/XE/system.dbf' resize 1000M;
alter database datafile '\$ORACLE_BASE/oradata/XE/sysaux.dbf' resize 700M;
alter database datafile '\$ORACLE_BASE/oradata/XE/undotbs1.dbf' resize 300M;
alter database add logfile group 4 '\$ORACLE_BASE/oradata/XE/redo04.log' size 500M reuse;
alter database add logfile group 5 '\$ORACLE_BASE/oradata/XE/redo05.log' size 500M reuse;
alter database add logfile group 6 '\$ORACLE_BASE/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 system set open_cursors=1000 sid='*' scope=both;
alter system set session_cached_cursors=500 sid='*' scope=spfile;
alter system set recyclebin=OFF sid='*' SCOPE=spfile;
alter system set processes=150 scope=spfile;
alter system set filesystemio_options=asynch scope=spfile;
alter system set disk_asynch_io=true scope=spfile;
shutdown immediate;
startup;
create user hibernate_orm_test identified by hibernate_orm_test quota unlimited on users;
grant all privileges to hibernate_orm_test;
EOF\""
# echo "Waiting for Oracle to restart after configuration..."
# $CONTAINER_CLI stop oracle
# $CONTAINER_CLI start oracle
# HEALTHSTATUS=
# until [ "$HEALTHSTATUS" == "healthy" ];
# do
# echo "Waiting for Oracle to start..."
# sleep 5;
# # On WSL, health-checks intervals don't work for Podman, so run them manually
# if command -v podman > /dev/null; then
# $CONTAINER_CLI healthcheck run oracle > /dev/null
# fi
# HEALTHSTATUS="`$CONTAINER_CLI inspect -f $HEALTCHECK_PATH oracle`"
# HEALTHSTATUS=${HEALTHSTATUS##+( )} #Remove longest matching series of spaces from the front
# HEALTHSTATUS=${HEALTHSTATUS%%+( )} #Remove longest matching series of spaces from the back
# done
# sleep 2;
echo "Oracle successfully started"
}
disable_userland_proxy() {
if [[ "$HEALTCHECK_PATH" == "{{.State.Health.Status}}" ]]; then
if [[ ! -f /etc/docker/daemon.json ]]; then
@ -754,19 +689,6 @@ oracle() {
oracle_23
}
oracle_11() {
$PRIVILEGED_CLI $CONTAINER_CLI rm -f oracle || true
# We need to use the defaults
# SYSTEM/Oracle18
$PRIVILEGED_CLI $CONTAINER_CLI run --name oracle -d -p 1521:1521 -e ORACLE_PASSWORD=Oracle18 \
--health-cmd healthcheck.sh \
--health-interval 5s \
--health-timeout 5s \
--health-retries 10 \
docker.io/gvenzl/oracle-xe:11.2.0.2-full
oracle_setup_old
}
oracle_21() {
$PRIVILEGED_CLI $CONTAINER_CLI rm -f oracle || true
disable_userland_proxy
@ -963,7 +885,6 @@ if [ -z ${1} ]; then
echo -e "\toracle"
echo -e "\toracle_23"
echo -e "\toracle_21"
echo -e "\toracle_11"
echo -e "\tpostgresql"
echo -e "\tpostgresql_15"
echo -e "\tpostgresql_14"

View File

@ -72,6 +72,8 @@ public class CommunityDialectSelector implements DialectSelector {
return Oracle9iDialect.class;
case "Oracle10g":
return Oracle10gDialect.class;
case "Oracle12c":
return Oracle12cDialect.class;
case "PostgreSQL81":
return PostgreSQL81Dialect.class;
case "PostgreSQL82":

View File

@ -4,7 +4,10 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.dialect;
package org.hibernate.community.dialect;
import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.OracleDialect;
/**
* An SQL dialect for Oracle 12c.

View File

@ -47,6 +47,7 @@ public class CommunityDialectSelectorTest {
testDialectNamingResolution( Oracle8iDialect.class );
testDialectNamingResolution( Oracle9iDialect.class );
testDialectNamingResolution( Oracle10gDialect.class );
testDialectNamingResolution( Oracle12cDialect.class );
testDialectNamingResolution( PostgreSQL81Dialect.class );
testDialectNamingResolution( PostgreSQL82Dialect.class );

View File

@ -26,7 +26,6 @@ import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.MariaDBDialect;
import org.hibernate.dialect.MySQL8Dialect;
import org.hibernate.dialect.MySQLDialect;
import org.hibernate.dialect.Oracle12cDialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.PostgresPlusDialect;
@ -99,9 +98,8 @@ public class DefaultDialectSelector implements DialectSelector {
case "Oracle8i":
case "Oracle9i":
case "Oracle10g":
return findCommunityDialect( name );
case "Oracle12c":
return Oracle12cDialect.class;
return findCommunityDialect( name );
case "PostgresPlus":
return PostgresPlusDialect.class;
case "PostgreSQL":

View File

@ -165,11 +165,9 @@ public class OracleDialect extends Dialect {
private static final String ADD_QUARTER_EXPRESSION = String.format( yqmSelect, "?2*3", "?3" );
private static final String ADD_MONTH_EXPRESSION = String.format( yqmSelect, "?2", "?3" );
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 11, 2 );
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 19 );
private final LimitHandler limitHandler = supportsFetchClause( FetchClauseType.ROWS_ONLY )
? Oracle12LimitHandler.INSTANCE
: new LegacyOracleLimitHandler( getVersion() );
private final LimitHandler limitHandler = Oracle12LimitHandler.INSTANCE;
private final UniqueDelegate uniqueDelegate = new CreateTableUniqueDelegate(this);
// Is it an Autonomous Database Cloud Service?
@ -298,12 +296,7 @@ public class OracleDialect extends Dialect {
typeConfiguration
).setArgumentListSignature("(pattern, string[, start])");
// The within group clause became optional in 18
if ( getVersion().isSameOrAfter( 18 ) ) {
functionFactory.listagg( null );
}
else {
functionFactory.listagg( "within group (order by rownum)" );
}
functionFactory.listagg( null );
functionFactory.windowFunctions();
functionFactory.hypotheticalOrderedSetAggregates();
functionFactory.inverseDistributionOrderedSetAggregates();
@ -374,7 +367,7 @@ public class OracleDialect extends Dialect {
@Override
public boolean supportsInsertReturningGeneratedKeys() {
return getVersion().isSameOrAfter( 12 );
return true;
}
/**
@ -710,7 +703,7 @@ public class OracleDialect extends Dialect {
if ( getVersion().isSameOrAfter( 21 ) ) {
ddlTypeRegistry.addDescriptor( new DdlTypeImpl( JSON, "json", this ) );
}
else if ( getVersion().isSameOrAfter( 12 ) ) {
else {
ddlTypeRegistry.addDescriptor( new DdlTypeImpl( JSON, "blob", this ) );
}
@ -726,8 +719,7 @@ public class OracleDialect extends Dialect {
@Override
protected void initDefaultProperties() {
super.initDefaultProperties();
getDefaultProperties().setProperty( BATCH_VERSIONED_DATA,
Boolean.toString( getVersion().isSameOrAfter( 12 ) ) );
getDefaultProperties().setProperty( BATCH_VERSIONED_DATA, "true" );
}
@Override
@ -741,7 +733,7 @@ public class OracleDialect extends Dialect {
// support the version taking an array of the names of the columns to
// be returned (via its RETURNING clause). No other driver seems to
// support this overloaded version.
return getVersion().isSameOrAfter( 12 );
return true;
}
@Override
@ -856,27 +848,25 @@ public class OracleDialect extends Dialect {
typeContributions.contributeJdbcType( OracleReflectionStructJdbcType.INSTANCE );
}
if ( getVersion().isSameOrAfter( 12 ) ) {
// account for Oracle's deprecated support for LONGVARBINARY
// prefer BLOB, unless the user explicitly opts out
boolean preferLong = serviceRegistry.getService( ConfigurationService.class ).getSetting(
PREFER_LONG_RAW,
StandardConverters.BOOLEAN,
false
);
// account for Oracle's deprecated support for LONGVARBINARY
// prefer BLOB, unless the user explicitly opts out
boolean preferLong = serviceRegistry.getService( ConfigurationService.class ).getSetting(
PREFER_LONG_RAW,
StandardConverters.BOOLEAN,
false
);
BlobJdbcType descriptor = preferLong ?
BlobJdbcType.PRIMITIVE_ARRAY_BINDING :
BlobJdbcType.DEFAULT;
BlobJdbcType descriptor = preferLong ?
BlobJdbcType.PRIMITIVE_ARRAY_BINDING :
BlobJdbcType.DEFAULT;
typeContributions.contributeJdbcType( descriptor );
typeContributions.contributeJdbcType( descriptor );
if ( getVersion().isSameOrAfter( 21 ) ) {
typeContributions.contributeJdbcType( OracleJsonJdbcType.INSTANCE );
}
else {
typeContributions.contributeJdbcType( OracleJsonBlobJdbcType.INSTANCE );
}
if ( getVersion().isSameOrAfter( 21 ) ) {
typeContributions.contributeJdbcType( OracleJsonJdbcType.INSTANCE );
}
else {
typeContributions.contributeJdbcType( OracleJsonBlobJdbcType.INSTANCE );
}
if ( OracleJdbcHelper.isUsable( serviceRegistry ) ) {
@ -923,9 +913,7 @@ public class OracleDialect extends Dialect {
@Override
public IdentityColumnSupport getIdentityColumnSupport() {
return getVersion().isBefore( 12 )
? super.getIdentityColumnSupport()
: Oracle12cIdentityColumnSupport.INSTANCE;
return Oracle12cIdentityColumnSupport.INSTANCE;
}
@Override
@ -1176,13 +1164,13 @@ public class OracleDialect extends Dialect {
public int getMaxAliasLength() {
// Max identifier length is 30 for pre 12.2 versions, and 128 for 12.2+
// but Hibernate needs to add "uniqueing info" so we account for that
return getVersion().isSameOrAfter( 12, 2 ) ? 118 : 20;
return 118;
}
@Override
public int getMaxIdentifierLength() {
// Since 12.2 version, maximum identifier length is 128
return getVersion().isSameOrAfter( 12, 2 ) ? 128 : 30;
return 128;
}
@Override
@ -1230,7 +1218,7 @@ public class OracleDialect extends Dialect {
public boolean supportsFetchClause(FetchClauseType type) {
// Until 12.2 there was a bug in the Oracle query rewriter causing ORA-00918
// when the query contains duplicate implicit aliases in the select clause
return getVersion().isSameOrAfter( 12, 2 );
return true;
}
@Override
@ -1245,7 +1233,7 @@ public class OracleDialect extends Dialect {
@Override
public boolean supportsLateral() {
return getVersion().isSameOrAfter( 12, 1 );
return true;
}
@Override

View File

@ -478,10 +478,6 @@ public class OracleSqlAstTranslator<T extends JdbcOperation> extends SqlAstTrans
appendSql("case when ");
expression.accept( this );
appendSql(" is not null then (select listagg(column_value||',')");
if ( !getDialect().getVersion().isSameOrAfter( 18 ) ) {
// The within group clause became optional in 18
appendSql(" within group(order by rownum)");
}
appendSql("||';' from table(");
expression.accept( this );
appendSql(")) else null end");

View File

@ -108,11 +108,6 @@ public class BatchOptimisticLockingTest extends
expected.getMessage().substring( 0, msg.length() )
);
}
else if ( getDialect() instanceof OracleDialect && getDialect().getVersion().isBefore( 12 ) ) {
assertTrue(
expected.getCause() instanceof StaleObjectStateException
);
}
else {
assertEquals(
"Batch update returned unexpected row count from update [1]; actual row count: 0; expected: 1; statement executed: update Person set name=?,version=? where id=? and version=?",

View File

@ -26,6 +26,7 @@ package org.hibernate.orm.test.cfg;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration;
import org.hibernate.community.dialect.OracleLegacyDialect;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.OracleDialect;
@ -74,8 +75,16 @@ public class BatchVersionedDataConfigTest extends BaseUnitTestCase {
}
@Test
public void testBatchVersionedDataForOracle10gDialect() {
public void testBatchVersionedDataForOracleDialect() {
cfg.setProperty( AvailableSettings.DIALECT, OracleDialect.class.getName() );
sessionFactory = cfg.buildSessionFactory();
assertThat( sessionFactory.getSessionFactoryOptions().isJdbcBatchVersionedData(), is( true ) );
}
@Test
public void testBatchVersionedDataForOracle10gDialect() {
cfg.setProperty( AvailableSettings.DIALECT, OracleLegacyDialect.class.getName() );
cfg.setProperty( AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION, "10" );
sessionFactory = cfg.buildSessionFactory();
@ -84,7 +93,7 @@ public class BatchVersionedDataConfigTest extends BaseUnitTestCase {
@Test
public void testBatchVersionedDataForOracle8iDialect() {
cfg.setProperty( AvailableSettings.DIALECT, OracleDialect.class.getName() );
cfg.setProperty( AvailableSettings.DIALECT, OracleLegacyDialect.class.getName() );
cfg.setProperty( AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION, "8" );
sessionFactory = cfg.buildSessionFactory();
@ -93,7 +102,7 @@ public class BatchVersionedDataConfigTest extends BaseUnitTestCase {
@Test
public void testBatchVersionedDataForOracle9iDialect() {
cfg.setProperty( AvailableSettings.DIALECT, OracleDialect.class.getName() );
cfg.setProperty( AvailableSettings.DIALECT, OracleLegacyDialect.class.getName() );
cfg.setProperty( AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION, "9" );
sessionFactory = cfg.buildSessionFactory();
@ -102,7 +111,7 @@ public class BatchVersionedDataConfigTest extends BaseUnitTestCase {
@Test
public void testBatchVersionedDataForOracle12cDialect() {
cfg.setProperty( AvailableSettings.DIALECT, OracleDialect.class.getName() );
cfg.setProperty( AvailableSettings.DIALECT, OracleLegacyDialect.class.getName() );
cfg.setProperty( AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION, "12" );
sessionFactory = cfg.buildSessionFactory();

View File

@ -24,12 +24,14 @@
package org.hibernate.orm.test.dialect;
import org.hibernate.cfg.Environment;
import org.hibernate.community.dialect.OracleLegacyDialect;
import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.OracleDialect;
import org.junit.Test;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.TestForIssue;
import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals;
@ -39,21 +41,21 @@ import static org.junit.Assert.assertEquals;
public class OracleDialectsTest {
@Test
@TestForIssue( jiraKey = "HHH-9990")
public void testDefaultBatchVersionDataProperty(){
OracleDialect oracleDialect = new OracleDialect();
assertEquals( "false", oracleDialect.getDefaultProperties().getProperty( Environment.BATCH_VERSIONED_DATA ) );
@JiraKey("HHH-9990")
public void testDefaultBatchVersionDataProperty() {
Dialect oracleDialect = new OracleDialect();
assertEquals( "true", oracleDialect.getDefaultProperties().getProperty( Environment.BATCH_VERSIONED_DATA ) );
OracleDialect oracle8iDialect = new OracleDialect( DatabaseVersion.make( 8 ) );
Dialect oracle8iDialect = new OracleLegacyDialect( DatabaseVersion.make( 8 ) );
assertEquals( "false", oracle8iDialect.getDefaultProperties().getProperty( Environment.BATCH_VERSIONED_DATA ) );
OracleDialect oracle10gDialect = new OracleDialect( DatabaseVersion.make( 10 ) );
Dialect oracle10gDialect = new OracleLegacyDialect( DatabaseVersion.make( 10 ) );
assertEquals( "false", oracle10gDialect.getDefaultProperties().getProperty( Environment.BATCH_VERSIONED_DATA ) );
OracleDialect oracle9iDialect = new OracleDialect( DatabaseVersion.make( 9 ) );
Dialect oracle9iDialect = new OracleLegacyDialect( DatabaseVersion.make( 9 ) );
assertEquals( "false", oracle9iDialect.getDefaultProperties().getProperty( Environment.BATCH_VERSIONED_DATA ) );
OracleDialect oracle12cDialect = new OracleDialect( DatabaseVersion.make( 12 ) );
Dialect oracle12cDialect = new OracleLegacyDialect( DatabaseVersion.make( 12 ) );
assertEquals( "true", oracle12cDialect.getDefaultProperties().getProperty( Environment.BATCH_VERSIONED_DATA ) );
}
}

View File

@ -12,6 +12,7 @@ import org.hibernate.community.dialect.DerbyTenSevenDialect;
import org.hibernate.community.dialect.DerbyTenSixDialect;
import org.hibernate.community.dialect.MySQL57Dialect;
import org.hibernate.community.dialect.MySQL5Dialect;
import org.hibernate.community.dialect.Oracle12cDialect;
import org.hibernate.community.dialect.SQLServer2008Dialect;
import org.hibernate.dialect.*;

View File

@ -18,7 +18,7 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.Oracle12cDialect;
import org.hibernate.community.dialect.Oracle12cDialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.type.BasicType;

View File

@ -32,7 +32,7 @@ stage('Configure') {
new BuildEnvironment( dbName: 'mariadb_10_4' ),
new BuildEnvironment( dbName: 'postgresql_12' ),
new BuildEnvironment( dbName: 'edb_12' ),
new BuildEnvironment( dbName: 'oracle_11_2' ),
new BuildEnvironment( dbName: 'oracle_21' ), // Did not find an image for Oracle-XE 19c
new BuildEnvironment( dbName: 'db2_10_5', longRunning: true ),
new BuildEnvironment( dbName: 'mssql_2017' ), // Unfortunately there is no SQL Server 2008 image, so we have to test with 2017
// new BuildEnvironment( dbName: 'sybase_16' ), // There only is a Sybase ASE 16 image, so no pint in testing that nightly
@ -137,11 +137,11 @@ stage('Build') {
sh "./docker_db.sh edb_12"
state[buildEnv.tag]['containerName'] = "edb"
break;
case "oracle_11_2":
case "oracle_21":
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
docker.image('gvenzl/oracle-xe:11.2.0.2-full').pull()
docker.image('gvenzl/oracle-xe:21.3.0-full').pull()
}
sh "./docker_db.sh oracle_11"
sh "./docker_db.sh oracle_21"
state[buildEnv.tag]['containerName'] = "oracle"
break;
case "db2_10_5":