From 307a58fe9a2203b9a4111641488220cd3caa5d2c Mon Sep 17 00:00:00 2001 From: Radek Felcman Date: Thu, 16 Nov 2023 14:37:18 +0100 Subject: [PATCH] Oracle 23C platform Adds support for Oracle 23c database. There are following changes - Oracle23Platform.java platform classes added - New Oracle JDBC driver 23.x.x.x has, in some cases, different behaviour for boolean type. There are changes in PL/SQL calls. - When empty String ("") is inserted into table column like ...CLOBDATA CLOB NOT NULL... Solution is based on conversion into java.sql.Clob, because solution based on SimpleAppendCallCustomParameter("empty_clob()") and DatabasePlatform.appendParameter() leads into another test failures. - Fix for loss of precision if DB table is automatically created if entity using java.time.LocalDateTime, java.time.LocalTime. - JDBC Driver update Signed-off-by: Radek Felcman --- buildsystem/compdeps/pom.xml | 4 +- .../VendorNameToPlatformMapping.properties | 4 +- .../core/databaseaccess/CorePlatform.java | 15 +++- .../databaseaccess/DatasourcePlatform.java | 26 ++++++ .../internal/databaseaccess/Platform.java | 20 ++++- .../converters/TypeConversionConverter.java | 9 +- .../platform/database/Oracle23Platform.java | 74 ++++++++++++++++ .../plsql/PLSQLStoredProcedureCall.java | 13 ++- .../database/oracle/Oracle23Platform.java | 84 +++++++++++++++++++ .../TestOracleLOBLocatorFeature.java | 5 +- jpa/eclipselink.jpa.test/antbuild.xml | 10 ++- .../tests/jpa/plsql/PLSQLTestSuite.java | 16 +++- .../jpa/metadata/converters/LobMetadata.java | 10 ++- 13 files changed, 270 insertions(+), 20 deletions(-) create mode 100644 foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/Oracle23Platform.java create mode 100644 foundation/org.eclipse.persistence.oracle/src/org/eclipse/persistence/platform/database/oracle/Oracle23Platform.java diff --git a/buildsystem/compdeps/pom.xml b/buildsystem/compdeps/pom.xml index 2cda2b21a36..f42f72bb4f9 100644 --- a/buildsystem/compdeps/pom.xml +++ b/buildsystem/compdeps/pom.xml @@ -112,8 +112,8 @@ 4.1.8.Final - 21.7.0.0 - 21.3.0.0 + 23.3.0.23.09 + 23.2.0.0 18.3.10 diff --git a/foundation/org.eclipse.persistence.core/resource/org/eclipse/persistence/internal/helper/VendorNameToPlatformMapping.properties b/foundation/org.eclipse.persistence.core/resource/org/eclipse/persistence/internal/helper/VendorNameToPlatformMapping.properties index 61bea2e55e8..ec5cafa8127 100644 --- a/foundation/org.eclipse.persistence.core/resource/org/eclipse/persistence/internal/helper/VendorNameToPlatformMapping.properties +++ b/foundation/org.eclipse.persistence.core/resource/org/eclipse/persistence/internal/helper/VendorNameToPlatformMapping.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1998, 2022 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1998, 2019 IBM Corporation. All rights reserved. # # This program and the accompanying materials are made available under the @@ -36,6 +36,7 @@ # to platform class entries should be placed before less specific entries. Each # platform entry must be on its own line, an entry cannot span multiple lines. +(?is)oracle.*23.*=org.eclipse.persistence.platform.database.oracle.Oracle23Platform (?is)oracle.*21.*=org.eclipse.persistence.platform.database.oracle.Oracle21Platform (?is)oracle.*19.*=org.eclipse.persistence.platform.database.oracle.Oracle19Platform (?is)oracle.*18.*=org.eclipse.persistence.platform.database.oracle.Oracle18Platform @@ -43,6 +44,7 @@ (?is)oracle.*11.*=org.eclipse.persistence.platform.database.oracle.Oracle11Platform (?is)oracle.*10.*=org.eclipse.persistence.platform.database.oracle.Oracle10Platform (?is)oracle.*9.*=org.eclipse.persistence.platform.database.oracle.Oracle9Platform +(?is)core.oracle.*23.*=org.eclipse.persistence.platform.database.Oracle23Platform (?is)core.oracle.*21.*=org.eclipse.persistence.platform.database.Oracle21Platform (?is)core.oracle.*19.*=org.eclipse.persistence.platform.database.Oracle19Platform (?is)core.oracle.*18.*=org.eclipse.persistence.platform.database.Oracle18Platform diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/core/databaseaccess/CorePlatform.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/core/databaseaccess/CorePlatform.java index 73ece276ba6..976fea6a96b 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/core/databaseaccess/CorePlatform.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/core/databaseaccess/CorePlatform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -14,7 +14,9 @@ // Blaise Doughan - 2.5 - initial implementation package org.eclipse.persistence.internal.core.databaseaccess; +import org.eclipse.persistence.exceptions.ConversionException; import org.eclipse.persistence.internal.core.helper.CoreConversionManager; +import org.eclipse.persistence.internal.sessions.AbstractSession; public interface CorePlatform { @@ -28,6 +30,17 @@ public interface CorePlatform */ Object convertObject(Object sourceObject, Class javaClass); + /** + * Convert the object to the appropriate type by invoking the appropriate + * ConversionManager method. + * @param sourceObject the object that must be converted + * @param javaClass the class that the object must be converted to + * @param session current database session + * @exception ConversionException all exceptions will be thrown as this type. + * @return the newly converted object + */ + Object convertObject(Object sourceObject, Class javaClass, AbstractSession session) throws ConversionException; + /** * The platform hold its own instance of conversion manager to allow customization. */ diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DatasourcePlatform.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DatasourcePlatform.java index e038039ae0c..a1f61c3acdf 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DatasourcePlatform.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/DatasourcePlatform.java @@ -244,6 +244,20 @@ public Object convertObject(Object sourceObject, Class javaClass) throws Convers return getConversionManager().convertObject(sourceObject, javaClass); } + /** + * Convert the object to the appropriate type by invoking the appropriate + * ConversionManager method. + * @param sourceObject the object that must be converted + * @param javaClass the class that the object must be converted to + * @param session current database session + * @exception ConversionException all exceptions will be thrown as this type. + * @return the newly converted object + */ + @Override + public Object convertObject(Object sourceObject, Class javaClass, AbstractSession session) throws ConversionException { + return convertObject(sourceObject, javaClass); + } + /** * Copy the state into the new platform. */ @@ -286,6 +300,13 @@ public void setConversionManager(ConversionManager conversionManager) { this.conversionManager = conversionManager; } + /** + * Return the driver version. + */ + public String getDriverVersion() { + return ""; + } + /** * Delimiter to use for fields and tables using spaces or other special values. * @@ -645,6 +666,11 @@ public boolean isOracle9() { return false; } + @Override + public boolean isOracle23() { + return false; + } + public boolean isPervasive(){ return false; } diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/Platform.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/Platform.java index 90c7cf4fa80..cd977cfcf31 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/Platform.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/internal/databaseaccess/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019 IBM Corporation. All rights reserved. * * This program and the accompanying materials are made available under the @@ -47,6 +47,17 @@ public interface Platform extends CorePlatform, Serializable, */ public Object convertObject(Object sourceObject, Class javaClass) throws ConversionException; + /** + * Convert the object to the appropriate type by invoking the appropriate + * ConversionManager method. + * @param sourceObject the object that must be converted + * @param javaClass the class that the object must be converted to + * @param session current database session + * @exception ConversionException all exceptions will be thrown as this type. + * @return the newly converted object + */ + public Object convertObject(Object sourceObject, Class javaClass, AbstractSession session) throws ConversionException; + /** * Copy the state into the new platform. */ @@ -63,6 +74,11 @@ public interface Platform extends CorePlatform, Serializable, */ public void setConversionManager(ConversionManager conversionManager); + /** + * Return the driver version. + */ + public String getDriverVersion(); + /** * Return the qualifier for the table. Required by some * databases such as Oracle and DB2 @@ -113,6 +129,8 @@ public interface Platform extends CorePlatform, Serializable, public boolean isOracle9(); + public boolean isOracle23(); + public boolean isPointBase(); public boolean isSQLAnywhere(); diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/mappings/converters/TypeConversionConverter.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/mappings/converters/TypeConversionConverter.java index 1d53d68ab8f..8cc5bbb7c07 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/mappings/converters/TypeConversionConverter.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/mappings/converters/TypeConversionConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -207,7 +207,12 @@ public void setObjectClassName(String objectClassName) { */ public Object convertObjectValueToDataValue(Object attributeValue, Session session) { try { - return ((AbstractSession)session).getDatasourcePlatform().convertObject(attributeValue, getDataClass()); + if (session.isConnected()) { + //Should handle conversions where DB connection is needed like String -> java.sql.Clob + return session.getDatasourcePlatform().convertObject(attributeValue, getDataClass(), (AbstractSession)session); + } else { + return session.getDatasourcePlatform().convertObject(attributeValue, getDataClass()); + } } catch (ConversionException e) { throw ConversionException.couldNotBeConverted(mapping, mapping.getDescriptor(), e); } diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/Oracle23Platform.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/Oracle23Platform.java new file mode 100644 index 00000000000..d23b12a84a5 --- /dev/null +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/Oracle23Platform.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ + +// Contributors: +// Oracle - initial API and implementation +package org.eclipse.persistence.platform.database; + +import org.eclipse.persistence.exceptions.ConversionException; +import org.eclipse.persistence.exceptions.DatabaseException; +import org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition; +import org.eclipse.persistence.internal.helper.ClassConstants; +import org.eclipse.persistence.internal.sessions.AbstractSession; + +import java.sql.Clob; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Hashtable; + +import static org.eclipse.persistence.internal.helper.StringHelper.EMPTY_STRING; + +public class Oracle23Platform extends Oracle21Platform { + public Oracle23Platform() { + super(); + } + + @Override + protected Hashtable, FieldTypeDefinition> buildFieldTypes() { + Hashtable, FieldTypeDefinition> fieldTypes = super.buildFieldTypes(); + fieldTypes.put(java.time.LocalDateTime.class, new FieldTypeDefinition("TIMESTAMP", 9)); + fieldTypes.put(java.time.LocalTime.class, new FieldTypeDefinition("TIMESTAMP", 9)); + return fieldTypes; + } + + /** + * INTERNAL: + * Check whether current platform is Oracle 23c or later. + * @return Always returns {@code true} for instances of Oracle 23c platform. + * @since 2.7.14 + */ + @Override + public boolean isOracle23() { + return true; + } + + /** + * INTERNAL: + * Allow for conversion from the Oracle type to the Java type. Used in cases when DB connection is needed like BLOB, CLOB. + */ + @Override + public Object convertObject(Object sourceObject, Class javaClass, AbstractSession session) throws ConversionException, DatabaseException { + //Handle special case when empty String ("") is passed from the entity into CLOB type column + if (ClassConstants.CLOB.equals(javaClass) && sourceObject instanceof String && EMPTY_STRING.equals(sourceObject)) { + Connection connection = session.getAccessor().getConnection(); + Clob clob = null; + try { + clob = connection.createClob(); + clob.setString(1, (String)sourceObject); + } catch (SQLException e) { + throw ConversionException.couldNotBeConvertedToClass(sourceObject, ClassConstants.CLOB, e); + } + return clob; + } + return super.convertObject(sourceObject, javaClass); + } +} \ No newline at end of file diff --git a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/oracle/plsql/PLSQLStoredProcedureCall.java b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/oracle/plsql/PLSQLStoredProcedureCall.java index 3e76801e59c..2269c4ba776 100644 --- a/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/oracle/plsql/PLSQLStoredProcedureCall.java +++ b/foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/platform/database/oracle/plsql/PLSQLStoredProcedureCall.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019, 2022 IBM Corporation. All rights reserved. * * This program and the accompanying materials are made available under the @@ -56,6 +56,8 @@ import org.eclipse.persistence.internal.sessions.AbstractRecord; import org.eclipse.persistence.internal.sessions.AbstractSession; import org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField; +import org.eclipse.persistence.platform.database.DatabasePlatform; +import org.eclipse.persistence.platform.database.jdbc.JDBCTypes; import org.eclipse.persistence.platform.database.oracle.jdbc.OracleArrayType; import org.eclipse.persistence.queries.StoredProcedureCall; import org.eclipse.persistence.sessions.DatabaseRecord; @@ -488,6 +490,7 @@ public void useNamedCursorOutputAsResultSet(String argumentName, DatabaseType da protected void assignIndices() { List inArguments = getArguments(arguments, ParameterType.IN); List inOutArguments = getArguments(arguments, ParameterType.INOUT); + DatabasePlatform platform = this.getQuery().getSession().getPlatform(); inArguments.addAll(inOutArguments); int newIndex = 1; List expandedArguments = new ArrayList(); @@ -509,6 +512,10 @@ protected void assignIndices() { } for (PLSQLargument inArg : inArguments) { DatabaseType type = inArg.databaseType; + if (platform.isOracle23() && type == OraclePLSQLTypes.PLSQLBoolean && Helper.compareVersions(platform.getDriverVersion(), "23.0.0") >= 0) { + type = JDBCTypes.BOOLEAN_TYPE; + inArg.databaseType = JDBCTypes.BOOLEAN_TYPE; + } String inArgName = inArg.name; if (!type.isComplexDatabaseType()) { // for XMLType, we need to set type name parameter (will be "XMLTYPE") @@ -562,6 +569,10 @@ protected void assignIndices() { super.useNamedCursorOutputAsResultSet(outArgName); } else { DatabaseType type = outArg.databaseType; + if (platform.isOracle23() && type == OraclePLSQLTypes.PLSQLBoolean && Helper.compareVersions(platform.getDriverVersion(), "23.0.0") >= 0) { + type = JDBCTypes.BOOLEAN_TYPE; + outArg.databaseType = JDBCTypes.BOOLEAN_TYPE; + } if (!type.isComplexDatabaseType()) { // for XMLType, we need to set type name parameter (will be "XMLTYPE") if (type == XMLType) { diff --git a/foundation/org.eclipse.persistence.oracle/src/org/eclipse/persistence/platform/database/oracle/Oracle23Platform.java b/foundation/org.eclipse.persistence.oracle/src/org/eclipse/persistence/platform/database/oracle/Oracle23Platform.java new file mode 100644 index 00000000000..6f4dffb10ec --- /dev/null +++ b/foundation/org.eclipse.persistence.oracle/src/org/eclipse/persistence/platform/database/oracle/Oracle23Platform.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0, + * or the Eclipse Distribution License v. 1.0 which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause + */ + +// Contributors: +// Oracle - initial API and implementation +package org.eclipse.persistence.platform.database.oracle; + +import org.eclipse.persistence.exceptions.ConversionException; +import org.eclipse.persistence.exceptions.DatabaseException; +import org.eclipse.persistence.internal.databaseaccess.FieldTypeDefinition; +import org.eclipse.persistence.internal.helper.ClassConstants; +import org.eclipse.persistence.internal.sessions.AbstractSession; + +import java.sql.Clob; +import java.sql.Connection; +import java.sql.SQLException; +import java.util.Hashtable; + +import static org.eclipse.persistence.internal.helper.StringHelper.EMPTY_STRING; + +/** + *

Purpose: + * Supports certain new Oracle 23c data types, and usage of certain Oracle JDBC specific APIs. + *

Supports Oracle JSON data type. + *

Supports Oracle OracleJsonValue derived Java types. + */ +public class Oracle23Platform extends Oracle21Platform { + + /** + * Creates an instance of Oracle 23c database platform. + */ + public Oracle23Platform() { + super(); + } + + /** + * INTERNAL: + * Check whether current platform is Oracle 23c or later. + * @return Always returns {@code true} for instances of Oracle 23c platform. + * @since 4.0.2 + */ + @Override + public boolean isOracle23() { + return true; + } + + @Override + protected Hashtable, FieldTypeDefinition> buildFieldTypes() { + Hashtable, FieldTypeDefinition> fieldTypes = super.buildFieldTypes(); + fieldTypes.put(java.time.LocalDateTime.class, new FieldTypeDefinition("TIMESTAMP", 9)); + fieldTypes.put(java.time.LocalTime.class, new FieldTypeDefinition("TIMESTAMP", 9)); + return fieldTypes; + } + + /** + * INTERNAL: + * Allow for conversion from the Oracle type to the Java type. Used in cases when DB connection is needed like BLOB, CLOB. + */ + @Override + public Object convertObject(Object sourceObject, Class javaClass, AbstractSession session) throws ConversionException, DatabaseException { + //Handle special case when empty String ("") is passed from the entity into CLOB type column + if (ClassConstants.CLOB.equals(javaClass) && sourceObject instanceof String && EMPTY_STRING.equals(sourceObject)) { + Connection connection = session.getAccessor().getConnection(); + Clob clob = null; + try { + clob = connection.createClob(); + clob.setString(1, (String)sourceObject); + } catch (SQLException e) { + throw ConversionException.couldNotBeConvertedToClass(sourceObject, ClassConstants.CLOB, e); + } + return clob; + } + return super.convertObject(sourceObject, javaClass); + } +} \ No newline at end of file diff --git a/jpa/eclipselink.jpa.test.jse/src/org/eclipse/persistence/jpa/test/oraclefeatures/TestOracleLOBLocatorFeature.java b/jpa/eclipselink.jpa.test.jse/src/org/eclipse/persistence/jpa/test/oraclefeatures/TestOracleLOBLocatorFeature.java index 1bb6212ed68..6448f524ec2 100644 --- a/jpa/eclipselink.jpa.test.jse/src/org/eclipse/persistence/jpa/test/oraclefeatures/TestOracleLOBLocatorFeature.java +++ b/jpa/eclipselink.jpa.test.jse/src/org/eclipse/persistence/jpa/test/oraclefeatures/TestOracleLOBLocatorFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2019 IBM Corporation. All rights reserved. * * This program and the accompanying materials are made available under the @@ -163,7 +163,8 @@ public void testOracleWithoutLOBLocatorWithEmptyClob() throws Exception { notAllowedPlatforms.add("org.eclipse.persistence.platform.database.Oracle8Platform"); notAllowedPlatforms.add("org.eclipse.persistence.platform.database.Oracle9Platform"); notAllowedPlatforms.add("org.eclipse.persistence.platform.database.Oracle10Platform"); - + notAllowedPlatforms.add("org.eclipse.persistence.platform.database.Oracle23Platform"); + notAllowedPlatforms.add("org.eclipse.persistence.platform.database.oracle.Oracle23Platform"); if (!checkIsOracle() || notAllowedPlatforms.contains(getPlatform(emfNoSessionCustomizer).getClass().getName())) { // Skip if not testing against Oracle diff --git a/jpa/eclipselink.jpa.test/antbuild.xml b/jpa/eclipselink.jpa.test/antbuild.xml index e642d52778a..4267808ee5e 100644 --- a/jpa/eclipselink.jpa.test/antbuild.xml +++ b/jpa/eclipselink.jpa.test/antbuild.xml @@ -2507,8 +2507,12 @@ - - + + + + @@ -2517,7 +2521,7 @@ - + diff --git a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/plsql/PLSQLTestSuite.java b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/plsql/PLSQLTestSuite.java index f6c4ba21c6a..09f9b2f1727 100644 --- a/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/plsql/PLSQLTestSuite.java +++ b/jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/plsql/PLSQLTestSuite.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -25,6 +25,7 @@ import org.eclipse.persistence.internal.databaseaccess.DatabaseCall; import org.eclipse.persistence.internal.helper.DatabaseType; +import org.eclipse.persistence.internal.helper.Helper; import org.eclipse.persistence.internal.jpa.EJBQueryImpl; import org.eclipse.persistence.platform.database.oracle.annotations.OracleArray; import org.eclipse.persistence.platform.database.oracle.annotations.PLSQLParameter; @@ -331,9 +332,16 @@ public void testSimpleFunction() { query.setParameter("P_POSITIVEN", 1); query.setParameter("P_SIGNTYPE", 1); query.setParameter("P_NUMBER", 1); - int result = (Integer)query.getSingleResult(); - if (result != 1) { - fail("Incorrect result."); + if (getPlatform().isOracle23() && Helper.compareVersions(getPlatform().getDriverVersion(), "23.0.0") >= 0) { + boolean result = (Boolean) query.getSingleResult(); + if (!result) { + fail("Incorrect result."); + } + } else { + int result = (Integer) query.getSingleResult(); + if (result != 1) { + fail("Incorrect result."); + } } } finally { closeEntityManagerAndTransaction(em); diff --git a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/converters/LobMetadata.java b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/converters/LobMetadata.java index ccd8291ecaf..d9c1d9f792a 100644 --- a/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/converters/LobMetadata.java +++ b/jpa/org.eclipse.persistence.jpa/src/org/eclipse/persistence/internal/jpa/metadata/converters/LobMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2018 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -119,10 +119,14 @@ public void process(DatabaseMapping mapping, MappingAccessor accessor, MetadataC // referenceClass type. if (isValidClobType(referenceClass)) { setFieldClassification(mapping, java.sql.Clob.class, isForMapKey); - setConverter(mapping, new TypeConversionConverter(mapping), isForMapKey); + TypeConversionConverter typeConversionConverter = new TypeConversionConverter(mapping); + typeConversionConverter.setDataClass(java.sql.Clob.class); + setConverter(mapping, typeConversionConverter, isForMapKey); } else if (isValidBlobType(referenceClass)) { setFieldClassification(mapping, java.sql.Blob.class, isForMapKey); - setConverter(mapping, new TypeConversionConverter(mapping), isForMapKey); + TypeConversionConverter typeConversionConverter = new TypeConversionConverter(mapping); + typeConversionConverter.setDataClass(java.sql.Blob.class); + setConverter(mapping, typeConversionConverter, isForMapKey); } else if (referenceClass.extendsInterface(Serializable.class)) { setFieldClassification(mapping, java.sql.Blob.class, isForMapKey); setConverter(mapping, new SerializedObjectConverter(mapping), isForMapKey);