Skip to content

Commit ed84edd

Browse files
jrenaatbeikov
authored andcommitted
HHH-17090 - Remove support for Oracle versions older than 19
Signed-off-by: Jan Schatteman <[email protected]>
1 parent ec639cd commit ed84edd

File tree

13 files changed

+67
-151
lines changed

13 files changed

+67
-151
lines changed

docker_db.sh

-79
Original file line numberDiff line numberDiff line change
@@ -617,71 +617,6 @@ grant all privileges to hibernate_orm_test;
617617
EOF\""
618618
}
619619

620-
oracle_setup_old() {
621-
HEALTHSTATUS=
622-
until [ "$HEALTHSTATUS" == "healthy" ];
623-
do
624-
echo "Waiting for Oracle to start..."
625-
sleep 5;
626-
# On WSL, health-checks intervals don't work for Podman, so run them manually
627-
if command -v podman > /dev/null; then
628-
$PRIVILEGED_CLI $CONTAINER_CLI healthcheck run oracle > /dev/null
629-
fi
630-
HEALTHSTATUS="`$PRIVILEGED_CLI $CONTAINER_CLI inspect -f $HEALTCHECK_PATH oracle`"
631-
HEALTHSTATUS=${HEALTHSTATUS##+( )} #Remove longest matching series of spaces from the front
632-
HEALTHSTATUS=${HEALTHSTATUS%%+( )} #Remove longest matching series of spaces from the back
633-
done
634-
# We increase file sizes to avoid online resizes as that requires lots of CPU which is restricted in XE
635-
$PRIVILEGED_CLI $CONTAINER_CLI exec oracle bash -c "source /home/oracle/.bashrc; bash -c \"
636-
cat <<EOF | \$ORACLE_HOME/bin/sqlplus / as sysdba
637-
alter database tempfile '\$ORACLE_BASE/oradata/XE/temp.dbf' resize 400M;
638-
alter database datafile '\$ORACLE_BASE/oradata/XE/system.dbf' resize 1000M;
639-
alter database datafile '\$ORACLE_BASE/oradata/XE/sysaux.dbf' resize 700M;
640-
alter database datafile '\$ORACLE_BASE/oradata/XE/undotbs1.dbf' resize 300M;
641-
alter database add logfile group 4 '\$ORACLE_BASE/oradata/XE/redo04.log' size 500M reuse;
642-
alter database add logfile group 5 '\$ORACLE_BASE/oradata/XE/redo05.log' size 500M reuse;
643-
alter database add logfile group 6 '\$ORACLE_BASE/oradata/XE/redo06.log' size 500M reuse;
644-
645-
alter system switch logfile;
646-
alter system switch logfile;
647-
alter system switch logfile;
648-
alter system checkpoint;
649-
650-
alter database drop logfile group 1;
651-
alter database drop logfile group 2;
652-
alter system set open_cursors=1000 sid='*' scope=both;
653-
alter system set session_cached_cursors=500 sid='*' scope=spfile;
654-
alter system set recyclebin=OFF sid='*' SCOPE=spfile;
655-
alter system set processes=150 scope=spfile;
656-
alter system set filesystemio_options=asynch scope=spfile;
657-
alter system set disk_asynch_io=true scope=spfile;
658-
659-
shutdown immediate;
660-
startup;
661-
662-
create user hibernate_orm_test identified by hibernate_orm_test quota unlimited on users;
663-
grant all privileges to hibernate_orm_test;
664-
EOF\""
665-
# echo "Waiting for Oracle to restart after configuration..."
666-
# $CONTAINER_CLI stop oracle
667-
# $CONTAINER_CLI start oracle
668-
# HEALTHSTATUS=
669-
# until [ "$HEALTHSTATUS" == "healthy" ];
670-
# do
671-
# echo "Waiting for Oracle to start..."
672-
# sleep 5;
673-
# # On WSL, health-checks intervals don't work for Podman, so run them manually
674-
# if command -v podman > /dev/null; then
675-
# $CONTAINER_CLI healthcheck run oracle > /dev/null
676-
# fi
677-
# HEALTHSTATUS="`$CONTAINER_CLI inspect -f $HEALTCHECK_PATH oracle`"
678-
# HEALTHSTATUS=${HEALTHSTATUS##+( )} #Remove longest matching series of spaces from the front
679-
# HEALTHSTATUS=${HEALTHSTATUS%%+( )} #Remove longest matching series of spaces from the back
680-
# done
681-
# sleep 2;
682-
echo "Oracle successfully started"
683-
}
684-
685620
disable_userland_proxy() {
686621
if [[ "$HEALTCHECK_PATH" == "{{.State.Health.Status}}" ]]; then
687622
if [[ ! -f /etc/docker/daemon.json ]]; then
@@ -754,19 +689,6 @@ oracle() {
754689
oracle_23
755690
}
756691

757-
oracle_11() {
758-
$PRIVILEGED_CLI $CONTAINER_CLI rm -f oracle || true
759-
# We need to use the defaults
760-
# SYSTEM/Oracle18
761-
$PRIVILEGED_CLI $CONTAINER_CLI run --name oracle -d -p 1521:1521 -e ORACLE_PASSWORD=Oracle18 \
762-
--health-cmd healthcheck.sh \
763-
--health-interval 5s \
764-
--health-timeout 5s \
765-
--health-retries 10 \
766-
docker.io/gvenzl/oracle-xe:11.2.0.2-full
767-
oracle_setup_old
768-
}
769-
770692
oracle_21() {
771693
$PRIVILEGED_CLI $CONTAINER_CLI rm -f oracle || true
772694
disable_userland_proxy
@@ -963,7 +885,6 @@ if [ -z ${1} ]; then
963885
echo -e "\toracle"
964886
echo -e "\toracle_23"
965887
echo -e "\toracle_21"
966-
echo -e "\toracle_11"
967888
echo -e "\tpostgresql"
968889
echo -e "\tpostgresql_15"
969890
echo -e "\tpostgresql_14"

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CommunityDialectSelector.java

+2
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public Class<? extends Dialect> resolve(String name) {
7272
return Oracle9iDialect.class;
7373
case "Oracle10g":
7474
return Oracle10gDialect.class;
75+
case "Oracle12c":
76+
return Oracle12cDialect.class;
7577
case "PostgreSQL81":
7678
return PostgreSQL81Dialect.class;
7779
case "PostgreSQL82":

hibernate-core/src/main/java/org/hibernate/dialect/Oracle12cDialect.java renamed to hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/Oracle12cDialect.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
55
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
66
*/
7-
package org.hibernate.dialect;
7+
package org.hibernate.community.dialect;
8+
9+
import org.hibernate.dialect.DatabaseVersion;
10+
import org.hibernate.dialect.OracleDialect;
811

912
/**
1013
* An SQL dialect for Oracle 12c.

hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/CommunityDialectSelectorTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void verifyAllDialectNamingResolve() {
4747
testDialectNamingResolution( Oracle8iDialect.class );
4848
testDialectNamingResolution( Oracle9iDialect.class );
4949
testDialectNamingResolution( Oracle10gDialect.class );
50+
testDialectNamingResolution( Oracle12cDialect.class );
5051

5152
testDialectNamingResolution( PostgreSQL81Dialect.class );
5253
testDialectNamingResolution( PostgreSQL82Dialect.class );

hibernate-core/src/main/java/org/hibernate/boot/registry/selector/internal/DefaultDialectSelector.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.hibernate.dialect.MariaDBDialect;
2727
import org.hibernate.dialect.MySQL8Dialect;
2828
import org.hibernate.dialect.MySQLDialect;
29-
import org.hibernate.dialect.Oracle12cDialect;
3029
import org.hibernate.dialect.OracleDialect;
3130
import org.hibernate.dialect.PostgreSQLDialect;
3231
import org.hibernate.dialect.PostgresPlusDialect;
@@ -99,9 +98,8 @@ public Class<? extends Dialect> resolve(final String name) {
9998
case "Oracle8i":
10099
case "Oracle9i":
101100
case "Oracle10g":
102-
return findCommunityDialect( name );
103101
case "Oracle12c":
104-
return Oracle12cDialect.class;
102+
return findCommunityDialect( name );
105103
case "PostgresPlus":
106104
return PostgresPlusDialect.class;
107105
case "PostgreSQL":

hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java

+28-40
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,9 @@ public class OracleDialect extends Dialect {
165165
private static final String ADD_QUARTER_EXPRESSION = String.format( yqmSelect, "?2*3", "?3" );
166166
private static final String ADD_MONTH_EXPRESSION = String.format( yqmSelect, "?2", "?3" );
167167

168-
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 11, 2 );
168+
private static final DatabaseVersion MINIMUM_VERSION = DatabaseVersion.make( 19 );
169169

170-
private final LimitHandler limitHandler = supportsFetchClause( FetchClauseType.ROWS_ONLY )
171-
? Oracle12LimitHandler.INSTANCE
172-
: new LegacyOracleLimitHandler( getVersion() );
170+
private final LimitHandler limitHandler = Oracle12LimitHandler.INSTANCE;
173171
private final UniqueDelegate uniqueDelegate = new CreateTableUniqueDelegate(this);
174172

175173
// Is it an Autonomous Database Cloud Service?
@@ -298,12 +296,7 @@ public void initializeFunctionRegistry(FunctionContributions functionContributio
298296
typeConfiguration
299297
).setArgumentListSignature("(pattern, string[, start])");
300298
// The within group clause became optional in 18
301-
if ( getVersion().isSameOrAfter( 18 ) ) {
302-
functionFactory.listagg( null );
303-
}
304-
else {
305-
functionFactory.listagg( "within group (order by rownum)" );
306-
}
299+
functionFactory.listagg( null );
307300
functionFactory.windowFunctions();
308301
functionFactory.hypotheticalOrderedSetAggregates();
309302
functionFactory.inverseDistributionOrderedSetAggregates();
@@ -374,7 +367,7 @@ public String currentTimestampWithTimeZone() {
374367

375368
@Override
376369
public boolean supportsInsertReturningGeneratedKeys() {
377-
return getVersion().isSameOrAfter( 12 );
370+
return true;
378371
}
379372

380373
/**
@@ -710,7 +703,7 @@ protected void registerColumnTypes(TypeContributions typeContributions, ServiceR
710703
if ( getVersion().isSameOrAfter( 21 ) ) {
711704
ddlTypeRegistry.addDescriptor( new DdlTypeImpl( JSON, "json", this ) );
712705
}
713-
else if ( getVersion().isSameOrAfter( 12 ) ) {
706+
else {
714707
ddlTypeRegistry.addDescriptor( new DdlTypeImpl( JSON, "blob", this ) );
715708
}
716709

@@ -726,8 +719,7 @@ public TimeZoneSupport getTimeZoneSupport() {
726719
@Override
727720
protected void initDefaultProperties() {
728721
super.initDefaultProperties();
729-
getDefaultProperties().setProperty( BATCH_VERSIONED_DATA,
730-
Boolean.toString( getVersion().isSameOrAfter( 12 ) ) );
722+
getDefaultProperties().setProperty( BATCH_VERSIONED_DATA, "true" );
731723
}
732724

733725
@Override
@@ -741,7 +733,7 @@ public boolean getDefaultUseGetGeneratedKeys() {
741733
// support the version taking an array of the names of the columns to
742734
// be returned (via its RETURNING clause). No other driver seems to
743735
// support this overloaded version.
744-
return getVersion().isSameOrAfter( 12 );
736+
return true;
745737
}
746738

747739
@Override
@@ -856,27 +848,25 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
856848
typeContributions.contributeJdbcType( OracleReflectionStructJdbcType.INSTANCE );
857849
}
858850

859-
if ( getVersion().isSameOrAfter( 12 ) ) {
860-
// account for Oracle's deprecated support for LONGVARBINARY
861-
// prefer BLOB, unless the user explicitly opts out
862-
boolean preferLong = serviceRegistry.getService( ConfigurationService.class ).getSetting(
863-
PREFER_LONG_RAW,
864-
StandardConverters.BOOLEAN,
865-
false
866-
);
851+
// account for Oracle's deprecated support for LONGVARBINARY
852+
// prefer BLOB, unless the user explicitly opts out
853+
boolean preferLong = serviceRegistry.getService( ConfigurationService.class ).getSetting(
854+
PREFER_LONG_RAW,
855+
StandardConverters.BOOLEAN,
856+
false
857+
);
867858

868-
BlobJdbcType descriptor = preferLong ?
869-
BlobJdbcType.PRIMITIVE_ARRAY_BINDING :
870-
BlobJdbcType.DEFAULT;
859+
BlobJdbcType descriptor = preferLong ?
860+
BlobJdbcType.PRIMITIVE_ARRAY_BINDING :
861+
BlobJdbcType.DEFAULT;
871862

872-
typeContributions.contributeJdbcType( descriptor );
863+
typeContributions.contributeJdbcType( descriptor );
873864

874-
if ( getVersion().isSameOrAfter( 21 ) ) {
875-
typeContributions.contributeJdbcType( OracleJsonJdbcType.INSTANCE );
876-
}
877-
else {
878-
typeContributions.contributeJdbcType( OracleJsonBlobJdbcType.INSTANCE );
879-
}
865+
if ( getVersion().isSameOrAfter( 21 ) ) {
866+
typeContributions.contributeJdbcType( OracleJsonJdbcType.INSTANCE );
867+
}
868+
else {
869+
typeContributions.contributeJdbcType( OracleJsonBlobJdbcType.INSTANCE );
880870
}
881871

882872
if ( OracleJdbcHelper.isUsable( serviceRegistry ) ) {
@@ -923,9 +913,7 @@ public String getNativeIdentifierGeneratorStrategy() {
923913

924914
@Override
925915
public IdentityColumnSupport getIdentityColumnSupport() {
926-
return getVersion().isBefore( 12 )
927-
? super.getIdentityColumnSupport()
928-
: Oracle12cIdentityColumnSupport.INSTANCE;
916+
return Oracle12cIdentityColumnSupport.INSTANCE;
929917
}
930918

931919
@Override
@@ -1176,13 +1164,13 @@ public String getQueryHintString(String sql, String hints) {
11761164
public int getMaxAliasLength() {
11771165
// Max identifier length is 30 for pre 12.2 versions, and 128 for 12.2+
11781166
// but Hibernate needs to add "uniqueing info" so we account for that
1179-
return getVersion().isSameOrAfter( 12, 2 ) ? 118 : 20;
1167+
return 118;
11801168
}
11811169

11821170
@Override
11831171
public int getMaxIdentifierLength() {
11841172
// Since 12.2 version, maximum identifier length is 128
1185-
return getVersion().isSameOrAfter( 12, 2 ) ? 128 : 30;
1173+
return 128;
11861174
}
11871175

11881176
@Override
@@ -1230,7 +1218,7 @@ public boolean supportsOffsetInSubquery() {
12301218
public boolean supportsFetchClause(FetchClauseType type) {
12311219
// Until 12.2 there was a bug in the Oracle query rewriter causing ORA-00918
12321220
// when the query contains duplicate implicit aliases in the select clause
1233-
return getVersion().isSameOrAfter( 12, 2 );
1221+
return true;
12341222
}
12351223

12361224
@Override
@@ -1245,7 +1233,7 @@ public boolean supportsRecursiveCTE() {
12451233

12461234
@Override
12471235
public boolean supportsLateral() {
1248-
return getVersion().isSameOrAfter( 12, 1 );
1236+
return true;
12491237
}
12501238

12511239
@Override

hibernate-core/src/main/java/org/hibernate/dialect/OracleSqlAstTranslator.java

-4
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,6 @@ private void arrayToString(Expression expression) {
478478
appendSql("case when ");
479479
expression.accept( this );
480480
appendSql(" is not null then (select listagg(column_value||',')");
481-
if ( !getDialect().getVersion().isSameOrAfter( 18 ) ) {
482-
// The within group clause became optional in 18
483-
appendSql(" within group(order by rownum)");
484-
}
485481
appendSql("||';' from table(");
486482
expression.accept( this );
487483
appendSql(")) else null end");

hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchOptimisticLockingTest.java

-5
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ public void testBatchAndOptimisticLocking() {
108108
expected.getMessage().substring( 0, msg.length() )
109109
);
110110
}
111-
else if ( getDialect() instanceof OracleDialect && getDialect().getVersion().isBefore( 12 ) ) {
112-
assertTrue(
113-
expected.getCause() instanceof StaleObjectStateException
114-
);
115-
}
116111
else {
117112
assertEquals(
118113
"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=?",

hibernate-core/src/test/java/org/hibernate/orm/test/cfg/BatchVersionedDataConfigTest.java

+13-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.hibernate.SessionFactory;
2727
import org.hibernate.cfg.AvailableSettings;
2828
import org.hibernate.cfg.Configuration;
29+
import org.hibernate.community.dialect.OracleLegacyDialect;
2930
import org.hibernate.dialect.H2Dialect;
3031
import org.hibernate.dialect.OracleDialect;
3132

@@ -74,8 +75,16 @@ public void testBatchVersionedDataForDialectNotSettingBatchVersionedDataProperty
7475
}
7576

7677
@Test
77-
public void testBatchVersionedDataForOracle10gDialect() {
78+
public void testBatchVersionedDataForOracleDialect() {
7879
cfg.setProperty( AvailableSettings.DIALECT, OracleDialect.class.getName() );
80+
sessionFactory = cfg.buildSessionFactory();
81+
82+
assertThat( sessionFactory.getSessionFactoryOptions().isJdbcBatchVersionedData(), is( true ) );
83+
}
84+
85+
@Test
86+
public void testBatchVersionedDataForOracle10gDialect() {
87+
cfg.setProperty( AvailableSettings.DIALECT, OracleLegacyDialect.class.getName() );
7988
cfg.setProperty( AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION, "10" );
8089
sessionFactory = cfg.buildSessionFactory();
8190

@@ -84,7 +93,7 @@ public void testBatchVersionedDataForOracle10gDialect() {
8493

8594
@Test
8695
public void testBatchVersionedDataForOracle8iDialect() {
87-
cfg.setProperty( AvailableSettings.DIALECT, OracleDialect.class.getName() );
96+
cfg.setProperty( AvailableSettings.DIALECT, OracleLegacyDialect.class.getName() );
8897
cfg.setProperty( AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION, "8" );
8998
sessionFactory = cfg.buildSessionFactory();
9099

@@ -93,7 +102,7 @@ public void testBatchVersionedDataForOracle8iDialect() {
93102

94103
@Test
95104
public void testBatchVersionedDataForOracle9iDialect() {
96-
cfg.setProperty( AvailableSettings.DIALECT, OracleDialect.class.getName() );
105+
cfg.setProperty( AvailableSettings.DIALECT, OracleLegacyDialect.class.getName() );
97106
cfg.setProperty( AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION, "9" );
98107
sessionFactory = cfg.buildSessionFactory();
99108

@@ -102,7 +111,7 @@ public void testBatchVersionedDataForOracle9iDialect() {
102111

103112
@Test
104113
public void testBatchVersionedDataForOracle12cDialect() {
105-
cfg.setProperty( AvailableSettings.DIALECT, OracleDialect.class.getName() );
114+
cfg.setProperty( AvailableSettings.DIALECT, OracleLegacyDialect.class.getName() );
106115
cfg.setProperty( AvailableSettings.JAKARTA_HBM2DDL_DB_MAJOR_VERSION, "12" );
107116
sessionFactory = cfg.buildSessionFactory();
108117

0 commit comments

Comments
 (0)