This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch past-M2 in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 26db089e6d3b778d8e88f87a302c884345a63c29 Author: Andrus Adamchik <[email protected]> AuthorDate: Sun May 31 12:17:43 2026 -0400 CAY-2956 Get rid of a dedicated adaper for Oracle 8 --- RELEASE-NOTES.txt | 11 + UPGRADE.md | 8 + .../org/apache/cayenne/dbsync/DbSyncModule.java | 2 - .../dbsync/reverse/configuration/ToolsModule.java | 2 - .../cayenne/configuration/runtime/CoreModule.java | 2 - .../cayenne/dba/oracle/Oracle8ActionBuilder.java | 58 ----- .../apache/cayenne/dba/oracle/Oracle8Adapter.java | 107 --------- .../cayenne/dba/oracle/Oracle8LOBBatchAction.java | 256 --------------------- .../dba/oracle/Oracle8LOBBatchQueryWrapper.java | 204 ---------------- .../dba/oracle/Oracle8LOBBatchTranslator.java | 166 ------------- .../oracle/Oracle8LOBInsertBatchTranslator.java | 65 ------ .../oracle/Oracle8LOBUpdateBatchTranslator.java | 73 ------ .../dba/oracle/Oracle8SQLTemplateAction.java | 88 ------- .../apache/cayenne/dba/oracle/OracleSniffer.java | 4 +- .../apache/cayenne/dba/oracle/types-oracle8.xml | 99 -------- .../runtime/DataDomainProviderTest.java | 2 - .../cayenne/dba/oracle/Oracle8AdapterIT.java | 64 ------ .../org/apache/cayenne/unit/dba/TestDbAdapter.java | 2 - .../cayenne/unit/util/SQLTemplateCustomizer.java | 3 - 19 files changed, 20 insertions(+), 1196 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 5462d7e07..7e76d73cf 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -7,6 +7,17 @@ https://cayenne.apache.org/ To browse individual bug reports check out project issue tracker: https://issues.apache.org/jira/browse/CAY +---------------------------------- +Release: 5.0-M3 +Date: +---------------------------------- +Changes/New Features: + +CAY-2956 Get rid of a dedicated adapter for Oracle 8 + +Bug Fixes: + + ---------------------------------- Release: 5.0-M2 Date: diff --git a/UPGRADE.md b/UPGRADE.md index 7554218f5..1882e9baf 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -53,6 +53,14 @@ Expression caseWhenExp = caseWhen( ``` +## Upgrading to 5.0.M3 + +* Per [CAY-2956](https://issues.apache.org/jira/browse/CAY-2956) the dedicated Oracle 8 adapter has been removed. + `org.apache.cayenne.dba.oracle.Oracle8Adapter` and its supporting classes no longer exist, and the + `OracleSniffer` now maps all Oracle versions to `OracleAdapter` regardless of the JDBC driver version. + If you referenced `Oracle8Adapter` explicitly (e.g. in a DataNode adapter configuration or custom DI + bindings), switch to `org.apache.cayenne.dba.oracle.OracleAdapter`. + ## Upgrading to 5.0.M2 * Per [CAY-2947](https://issues.apache.org/jira/browse/CAY-2947) the `cayenne-commitlog` artifact has been removed. Commit log support is now part of the diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/DbSyncModule.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/DbSyncModule.java index d8f33031d..cadcdccd8 100644 --- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/DbSyncModule.java +++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/DbSyncModule.java @@ -26,7 +26,6 @@ import org.apache.cayenne.dba.h2.H2Adapter; import org.apache.cayenne.dba.hsqldb.HSQLDBAdapter; import org.apache.cayenne.dba.ingres.IngresAdapter; import org.apache.cayenne.dba.mysql.MySQLAdapter; -import org.apache.cayenne.dba.oracle.Oracle8Adapter; import org.apache.cayenne.dba.oracle.OracleAdapter; import org.apache.cayenne.dba.postgres.PostgresAdapter; import org.apache.cayenne.dba.sqlserver.SQLServerAdapter; @@ -78,7 +77,6 @@ public class DbSyncModule implements Module { .put(IngresAdapter.class.getName(), IngresMergerTokenFactory.class) .put(MySQLAdapter.class.getName(), MySQLMergerTokenFactory.class) .put(OracleAdapter.class.getName(), OracleMergerTokenFactory.class) - .put(Oracle8Adapter.class.getName(), OracleMergerTokenFactory.class) .put(PostgresAdapter.class.getName(), PostgresMergerTokenFactory.class) .put(SQLServerAdapter.class.getName(), SQLServerMergerTokenFactory.class) .put(SybaseAdapter.class.getName(), SybaseMergerTokenFactory.class); diff --git a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java index 8269745d2..033d39187 100644 --- a/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java +++ b/cayenne-dbsync/src/main/java/org/apache/cayenne/dbsync/reverse/configuration/ToolsModule.java @@ -65,7 +65,6 @@ import org.apache.cayenne.dba.mariadb.MariaDBSniffer; import org.apache.cayenne.dba.mysql.MySQLAdapter; import org.apache.cayenne.dba.mysql.MySQLPkGenerator; import org.apache.cayenne.dba.mysql.MySQLSniffer; -import org.apache.cayenne.dba.oracle.Oracle8Adapter; import org.apache.cayenne.dba.oracle.OracleAdapter; import org.apache.cayenne.dba.oracle.OraclePkGenerator; import org.apache.cayenne.dba.oracle.OracleSniffer; @@ -139,7 +138,6 @@ public class ToolsModule implements Module { .addPkGenerator(IngresAdapter.class, IngresPkGenerator.class) .addPkGenerator(MySQLAdapter.class, MySQLPkGenerator.class) .addPkGenerator(OracleAdapter.class, OraclePkGenerator.class) - .addPkGenerator(Oracle8Adapter.class, OraclePkGenerator.class) .addPkGenerator(PostgresAdapter.class, PostgresPkGenerator.class) .addPkGenerator(SQLServerAdapter.class, SybasePkGenerator.class) .addPkGenerator(SybaseAdapter.class, SybasePkGenerator.class); diff --git a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/CoreModule.java b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/CoreModule.java index 9954c5db7..50dc4f8df 100644 --- a/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/CoreModule.java +++ b/cayenne/src/main/java/org/apache/cayenne/configuration/runtime/CoreModule.java @@ -88,7 +88,6 @@ import org.apache.cayenne.dba.mariadb.MariaDBSniffer; import org.apache.cayenne.dba.mysql.MySQLAdapter; import org.apache.cayenne.dba.mysql.MySQLPkGenerator; import org.apache.cayenne.dba.mysql.MySQLSniffer; -import org.apache.cayenne.dba.oracle.Oracle8Adapter; import org.apache.cayenne.dba.oracle.OracleAdapter; import org.apache.cayenne.dba.oracle.OraclePkGenerator; import org.apache.cayenne.dba.oracle.OracleSniffer; @@ -370,7 +369,6 @@ public class CoreModule implements Module { .addPkGenerator(IngresAdapter.class, IngresPkGenerator.class) .addPkGenerator(MySQLAdapter.class, MySQLPkGenerator.class) .addPkGenerator(OracleAdapter.class, OraclePkGenerator.class) - .addPkGenerator(Oracle8Adapter.class, OraclePkGenerator.class) .addPkGenerator(PostgresAdapter.class, PostgresPkGenerator.class) .addPkGenerator(SQLServerAdapter.class, SybasePkGenerator.class) .addPkGenerator(SybaseAdapter.class, SybasePkGenerator.class) diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8ActionBuilder.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8ActionBuilder.java deleted file mode 100644 index b6f5b0ff7..000000000 --- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8ActionBuilder.java +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.dba.oracle; - -import org.apache.cayenne.access.DataNode; -import org.apache.cayenne.query.BatchQuery; -import org.apache.cayenne.query.SQLAction; -import org.apache.cayenne.query.SQLTemplate; - -/** - * An action builder for Oracle8Adapter. - * - * @since 1.2 - */ -class Oracle8ActionBuilder extends OracleActionBuilder { - - Oracle8ActionBuilder(DataNode dataNode) { - super(dataNode); - } - - @Override - public SQLAction sqlAction(SQLTemplate query) { - return new Oracle8SQLTemplateAction(query, dataNode); - } - - @Override - public SQLAction batchAction(BatchQuery query) { - // special handling for LOB updates - if (OracleAdapter.isSupportsOracleLOB() && OracleAdapter.updatesLOBColumns(query)) { - // Special action for Oracle8. See CAY-1307. - return new Oracle8LOBBatchAction(query, dataNode.getAdapter(), dataNode.getJdbcEventLogger()); - } else { - // optimistic locking is not supported in batches due to JDBC driver - // limitations - boolean useOptimisticLock = query.isUsingOptimisticLocking(); - boolean runningAsBatch = !useOptimisticLock && dataNode.getAdapter().supportsBatchUpdates(); - - return new OracleBatchAction(query, dataNode, runningAsBatch); - } - } -} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8Adapter.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8Adapter.java deleted file mode 100644 index 2cb4a839e..000000000 --- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8Adapter.java +++ /dev/null @@ -1,107 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.dba.oracle; - -import org.apache.cayenne.access.DataNode; -import org.apache.cayenne.access.types.ExtendedType; -import org.apache.cayenne.access.types.ExtendedTypeFactory; -import org.apache.cayenne.access.types.ValueObjectTypeRegistry; -import org.apache.cayenne.configuration.Constants; -import org.apache.cayenne.configuration.RuntimeProperties; -import org.apache.cayenne.di.Inject; -import org.apache.cayenne.query.Query; -import org.apache.cayenne.query.SQLAction; -import org.apache.cayenne.resource.ResourceLocator; - -import java.lang.reflect.Method; -import java.net.URL; -import java.sql.Types; -import java.util.List; - -/** - * A flavor of OracleAdapter that implements workarounds for some old driver - * limitations. - * - * @since 1.2 - */ -public class Oracle8Adapter extends OracleAdapter { - - private static Method outputStreamFromBlobMethod; - private static Method writerFromClobMethod; - - static { - initOracle8DriverInformation(); - } - - public Oracle8Adapter(@Inject RuntimeProperties runtimeProperties, - @Inject(Constants.DEFAULT_TYPES_LIST) List<ExtendedType> defaultExtendedTypes, - @Inject(Constants.USER_TYPES_LIST) List<ExtendedType> userExtendedTypes, - @Inject(Constants.TYPE_FACTORIES_LIST) List<ExtendedTypeFactory> extendedTypeFactories, - @Inject(Constants.RESOURCE_LOCATOR) ResourceLocator resourceLocator, - @Inject ValueObjectTypeRegistry valueObjectTypeRegistry) { - super(runtimeProperties, defaultExtendedTypes, userExtendedTypes, extendedTypeFactories, resourceLocator, valueObjectTypeRegistry); - } - - private static void initOracle8DriverInformation() { - initDone = true; - - // configure static information - try { - outputStreamFromBlobMethod = Class.forName("oracle.sql.BLOB").getMethod("getBinaryOutputStream"); - writerFromClobMethod = Class.forName("oracle.sql.CLOB").getMethod("getCharacterOutputStream"); - } catch (Throwable th) { - // ignoring... - } - } - - static Method getWriterFromClobMethod() { - return writerFromClobMethod; - } - - static Method getOutputStreamFromBlobMethod() { - return outputStreamFromBlobMethod; - } - - /** - * Uses OracleActionBuilder to create the right action. - */ - @Override - public SQLAction getAction(Query query, DataNode node) { - return query.createSQLAction(new Oracle8ActionBuilder(node)); - } - - @Override - protected URL findResource(String name) { - - if ("/types.xml".equals(name)) { - name = "/types-oracle8.xml"; - } - - return super.findResource(name); - } - - /** - * @since 5.0 - */ - @Override - public boolean typeSupportsScale(int type) { - return type != Types.TIMESTAMP && super.typeSupportsScale(type); - } -} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchAction.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchAction.java deleted file mode 100644 index 14b3efc20..000000000 --- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchAction.java +++ /dev/null @@ -1,256 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.dba.oracle; - -import org.apache.cayenne.CayenneRuntimeException; -import org.apache.cayenne.access.OperationObserver; -import org.apache.cayenne.access.translator.ParameterBinding; -import org.apache.cayenne.access.types.ExtendedType; -import org.apache.cayenne.dba.DbAdapter; -import org.apache.cayenne.log.JdbcEventLogger; -import org.apache.cayenne.map.DbAttribute; -import org.apache.cayenne.query.BatchQuery; -import org.apache.cayenne.query.BatchQueryRow; -import org.apache.cayenne.query.InsertBatchQuery; -import org.apache.cayenne.query.SQLAction; -import org.apache.cayenne.query.UpdateBatchQuery; -import org.apache.cayenne.util.Util; - -import java.io.OutputStream; -import java.io.Writer; -import java.lang.reflect.Method; -import java.sql.Blob; -import java.sql.Clob; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.Types; -import java.util.List; - -/** - * @since 3.0 - */ -class Oracle8LOBBatchAction implements SQLAction { - - private final BatchQuery query; - private final DbAdapter adapter; - private final JdbcEventLogger logger; - - Oracle8LOBBatchAction(BatchQuery query, DbAdapter adapter, JdbcEventLogger logger) { - this.adapter = adapter; - this.query = query; - this.logger = logger; - } - - @Override - public void performAction(Connection connection, OperationObserver observer) throws Exception { - - Oracle8LOBBatchTranslator translator; - if (query instanceof InsertBatchQuery) { - translator = new Oracle8LOBInsertBatchTranslator((InsertBatchQuery) query, adapter, - OracleAdapter.TRIM_FUNCTION); - } else if (query instanceof UpdateBatchQuery) { - translator = new Oracle8LOBUpdateBatchTranslator((UpdateBatchQuery) query, adapter, - OracleAdapter.TRIM_FUNCTION); - } else { - throw new CayenneRuntimeException("Unsupported batch type for special LOB processing: " + query); - } - - translator.setNewBlobFunction(OracleAdapter.NEW_BLOB_FUNCTION); - translator.setNewClobFunction(OracleAdapter.NEW_CLOB_FUNCTION); - - // no batching is done, queries are translated - // for each batch set, since prepared statements - // may be different depending on whether LOBs are NULL or not.. - - Oracle8LOBBatchQueryWrapper selectQuery = new Oracle8LOBBatchQueryWrapper(query); - List<DbAttribute> qualifierAttributes = selectQuery.getDbAttributesForLOBSelectQualifier(); - - for (BatchQueryRow row : query.getRows()) { - - selectQuery.indexLOBAttributes(row); - - int updated; - String updateStr = translator.createSql(row); - - // 1. run row update - logger.log(updateStr); - - try (PreparedStatement statement = connection.prepareStatement(updateStr)) { - - ParameterBinding[] bindings = translator.updateBindings(row); - logger.logQueryParameters("bind", bindings); - - for (ParameterBinding b : bindings) { - if (!b.isDisabled()) { - adapter.bindParameter(statement, b); - } - } - - updated = statement.executeUpdate(); - logger.logUpdateCount(updated); - } - - // 2. run row LOB update (SELECT...FOR UPDATE and writing out LOBs) - processLOBRow(connection, translator, selectQuery, qualifierAttributes, row); - - // finally, notify delegate that the row was updated - observer.nextCount(query, updated); - } - } - - void processLOBRow(Connection con, Oracle8LOBBatchTranslator queryBuilder, Oracle8LOBBatchQueryWrapper selectQuery, - List<DbAttribute> qualifierAttributes, BatchQueryRow row) throws Exception { - - List<DbAttribute> lobAttributes = selectQuery.getDbAttributesForUpdatedLOBColumns(); - if (lobAttributes.isEmpty()) { - return; - } - - final boolean isLoggable = logger.isLoggable(); - - List<Object> qualifierValues = selectQuery.getValuesForLOBSelectQualifier(row); - List<Object> lobValues = selectQuery.getValuesForUpdatedLOBColumns(); - int parametersSize = qualifierValues.size(); - int lobSize = lobAttributes.size(); - - String selectStr = queryBuilder.createLOBSelectString(lobAttributes, qualifierAttributes); - - try (PreparedStatement selectStatement = con.prepareStatement(selectStr)) { - ParameterBinding[] attributeBindings = null; - if(isLoggable) { - attributeBindings = new ParameterBinding[parametersSize]; - } - for (int i = 0; i < parametersSize; i++) { - DbAttribute attribute = qualifierAttributes.get(i); - Object value = qualifierValues.get(i); - ExtendedType<?> extendedType = value != null - ? adapter.getExtendedTypes().getRegisteredType(value.getClass()) - : adapter.getExtendedTypes().getDefaultType(); - - ParameterBinding binding = new ParameterBinding( - adapter.preferredBindingType(attribute.getType()), attribute.getScale(), attribute - ); - binding.reset(i + 1, value, extendedType); - adapter.bindParameter(selectStatement, binding); - if(isLoggable) { - attributeBindings[i] = binding; - } - } - - if (isLoggable) { - logger.logQuery(selectStr, attributeBindings); - } - - try (ResultSet result = selectStatement.executeQuery()) { - if (!result.next()) { - throw new CayenneRuntimeException("Missing LOB row."); - } - - // read the only expected row - for (int i = 0; i < lobSize; i++) { - DbAttribute attribute = lobAttributes.get(i); - int type = attribute.getType(); - - if (type == Types.CLOB) { - Clob clob = result.getClob(i + 1); - Object clobVal = lobValues.get(i); - - if (clobVal instanceof char[]) { - writeClob(clob, (char[]) clobVal); - } else { - writeClob(clob, clobVal.toString()); - } - } else if (type == Types.BLOB) { - Blob blob = result.getBlob(i + 1); - - Object blobVal = lobValues.get(i); - if (blobVal instanceof byte[]) { - writeBlob(blob, (byte[]) blobVal); - } else { - String className = (blobVal != null) ? blobVal.getClass().getName() : null; - throw new CayenneRuntimeException("Unsupported class of BLOB value: %s", className); - } - } else { - throw new CayenneRuntimeException("Only BLOB or CLOB is expected here, got: %s", type); - } - } - - if (result.next()) { - throw new CayenneRuntimeException("More than one LOB row found."); - } - } - } - } - - /** - * Override the Oracle writeBlob() method to be compatible with Oracle8 - * drivers. - */ - protected void writeBlob(Blob blob, byte[] value) { - // Fix for CAY-1307. For Oracle8, get the method found by reflection in - // OracleAdapter. (Code taken from Cayenne 2.) - Method getBinaryStreamMethod = Oracle8Adapter.getOutputStreamFromBlobMethod(); - try { - - try (OutputStream out = (OutputStream) getBinaryStreamMethod.invoke(blob, (Object[]) null)) { - out.write(value); - out.flush(); - } - } catch (Exception e) { - throw new CayenneRuntimeException("Error processing BLOB.", Util.unwindException(e)); - } - } - - /** - * Override the Oracle writeClob() method to be compatible with Oracle8 - * drivers. - */ - protected void writeClob(Clob clob, char[] value) { - Method getWriterMethod = Oracle8Adapter.getWriterFromClobMethod(); - try { - - try (Writer out = (Writer) getWriterMethod.invoke(clob, (Object[]) null)) { - out.write(value); - out.flush(); - } - - } catch (Exception e) { - throw new CayenneRuntimeException("Error processing CLOB.", Util.unwindException(e)); - } - } - - /** - * Override the Oracle writeClob() method to be compatible with Oracle8 - * drivers. - */ - protected void writeClob(Clob clob, String value) { - Method getWriterMethod = Oracle8Adapter.getWriterFromClobMethod(); - try { - - try (Writer out = (Writer) getWriterMethod.invoke(clob, (Object[]) null)) { - out.write(value); - out.flush(); - } - } catch (Exception e) { - throw new CayenneRuntimeException("Error processing CLOB.", Util.unwindException(e)); - } - } -} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchQueryWrapper.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchQueryWrapper.java deleted file mode 100644 index 427dc9f74..000000000 --- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchQueryWrapper.java +++ /dev/null @@ -1,204 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.dba.oracle; - -import org.apache.cayenne.CayenneRuntimeException; -import org.apache.cayenne.map.DbAttribute; -import org.apache.cayenne.query.BatchQuery; -import org.apache.cayenne.query.BatchQueryRow; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.io.Serializable; -import java.sql.Types; -import java.util.ArrayList; -import java.util.List; - -/** - * Helper class to extract the information from BatchQueries, essential for LOB - * columns processing. - * - */ -class Oracle8LOBBatchQueryWrapper { - - protected BatchQuery query; - - protected List<DbAttribute> dbAttributes; - - // attribute list decoders - protected boolean[] qualifierAttributes; - protected boolean[] allLOBAttributes; - protected Object[] updatedLOBAttributes; - - Oracle8LOBBatchQueryWrapper(BatchQuery query) { - this.query = query; - this.dbAttributes = query.getDbAttributes(); - - int len = dbAttributes.size(); - this.qualifierAttributes = new boolean[len]; - this.allLOBAttributes = new boolean[len]; - this.updatedLOBAttributes = new Object[len]; - - indexQualifierAttributes(); - } - - /** - * Indexes attributes - */ - protected void indexQualifierAttributes() { - int len = this.dbAttributes.size(); - for (int i = 0; i < len; i++) { - DbAttribute attribute = this.dbAttributes.get(i); - int type = attribute.getType(); - qualifierAttributes[i] = attribute.isPrimaryKey(); - allLOBAttributes[i] = type == Types.BLOB || type == Types.CLOB; - } - } - - /** - * Indexes attributes - */ - void indexLOBAttributes(BatchQueryRow row) { - int len = updatedLOBAttributes.length; - for (int i = 0; i < len; i++) { - updatedLOBAttributes[i] = null; - - if (allLOBAttributes[i]) { - // skip null and empty LOBs - Object value = row.getValue(i); - - if (value == null) { - continue; - } - - if (dbAttributes.get(i).getType() == Types.BLOB) { - updatedLOBAttributes[i] = convertToBlobValue(value); - } else { - updatedLOBAttributes[i] = convertToClobValue(value); - } - } - } - } - - /** - * Converts value to byte[] if possible. - */ - protected byte[] convertToBlobValue(Object value) { - if (value instanceof byte[]) { - byte[] bytes = (byte[]) value; - return bytes.length == 0 ? null : bytes; - } else if (value instanceof Serializable) { - ByteArrayOutputStream bytes = new ByteArrayOutputStream() { - - @Override - public synchronized byte[] toByteArray() { - return buf; - } - }; - - try (ObjectOutputStream out = new ObjectOutputStream(bytes)) { - out.writeObject(value); - } catch (IOException e) { - throw new CayenneRuntimeException("Error serializing object", e); - } - - return bytes.toByteArray(); - } - - return null; - } - - /** - * Converts to char[] or String. Both are acceptable when writing CLOBs. - */ - protected Object convertToClobValue(Object value) { - - if (value instanceof char[]) { - char[] chars = (char[]) value; - return chars.length == 0 ? null : chars; - } else { - String strValue = value.toString(); - return strValue.length() == 0 ? null : strValue; - } - } - - /** - * Returns a list of DbAttributes used in the qualifier of the query that - * selects a LOB row for LOB update. - */ - List<DbAttribute> getDbAttributesForLOBSelectQualifier() { - - int len = qualifierAttributes.length; - List<DbAttribute> attributes = new ArrayList<>(len); - - for (int i = 0; i < len; i++) { - if (this.qualifierAttributes[i]) { - attributes.add(this.dbAttributes.get(i)); - } - } - return attributes; - } - - /** - * Returns a list of DbAttributes that correspond to the LOB columns updated - * in the current row in the batch query. The list will not include LOB - * attributes that are null or empty. - */ - List<DbAttribute> getDbAttributesForUpdatedLOBColumns() { - - int len = updatedLOBAttributes.length; - List<DbAttribute> attributes = new ArrayList<>(len); - - for (int i = 0; i < len; i++) { - if (this.updatedLOBAttributes[i] != null) { - attributes.add(this.dbAttributes.get(i)); - } - } - return attributes; - } - - List<Object> getValuesForLOBSelectQualifier(BatchQueryRow row) { - - int len = this.qualifierAttributes.length; - List<Object> values = new ArrayList<>(len); - for (int i = 0; i < len; i++) { - if (this.qualifierAttributes[i]) { - values.add(row.getValue(i)); - } - } - - return values; - } - - List<Object> getValuesForUpdatedLOBColumns() { - - int len = this.updatedLOBAttributes.length; - List<Object> values = new ArrayList<>(len); - for (Object updatedLOBAttribute : this.updatedLOBAttributes) { - if (updatedLOBAttribute != null) { - values.add(updatedLOBAttribute); - } - } - - return values; - } - -} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchTranslator.java deleted file mode 100644 index 291a8b9be..000000000 --- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBBatchTranslator.java +++ /dev/null @@ -1,166 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.dba.oracle; - -import org.apache.cayenne.CayenneRuntimeException; -import org.apache.cayenne.access.translator.ParameterBinding; -import org.apache.cayenne.access.translator.batch.legacy.DefaultBatchTranslator; -import org.apache.cayenne.access.types.ExtendedType; -import org.apache.cayenne.dba.DbAdapter; -import org.apache.cayenne.dba.QuotingStrategy; -import org.apache.cayenne.dba.TypesMapping; -import org.apache.cayenne.map.DbAttribute; -import org.apache.cayenne.query.BatchQuery; -import org.apache.cayenne.query.BatchQueryRow; - -import java.sql.Types; -import java.util.Iterator; -import java.util.List; - -/** - * Superclass of query builders for the DML operations involving LOBs. - * TODO: update to the new batch translation logic - */ -abstract class Oracle8LOBBatchTranslator extends DefaultBatchTranslator { - - protected String newClobFunction; - protected String newBlobFunction; - - Oracle8LOBBatchTranslator(BatchQuery query, DbAdapter adapter, String trimFunction) { - super(query, adapter, trimFunction); - } - - abstract String createSql(BatchQueryRow row); - - @Override - protected String createSql() { - throw new UnsupportedOperationException(); - } - - String createLOBSelectString(List<DbAttribute> selectedLOBAttributes, List<DbAttribute> qualifierAttributes) { - - QuotingStrategy strategy = adapter.getQuotingStrategy(); - - StringBuilder buf = new StringBuilder(); - buf.append("SELECT "); - - Iterator<DbAttribute> it = selectedLOBAttributes.iterator(); - while (it.hasNext()) { - buf.append(strategy.quotedName(it.next())); - - if (it.hasNext()) { - buf.append(", "); - } - } - - buf.append(" FROM ").append(strategy.quotedFullyQualifiedName(query.getDbEntity())).append(" WHERE "); - - it = qualifierAttributes.iterator(); - while (it.hasNext()) { - DbAttribute attribute = it.next(); - appendDbAttribute(buf, attribute); - buf.append(" = ?"); - if (it.hasNext()) { - buf.append(" AND "); - } - } - - buf.append(" FOR UPDATE"); - return buf.toString(); - } - - /** - * Appends parameter placeholder for the value of the column being updated. - * If requested, performs special handling on LOB columns. - */ - protected void appendUpdatedParameter(StringBuilder buf, DbAttribute dbAttribute, Object value) { - - int type = dbAttribute.getType(); - - if (isUpdateableColumn(value, type)) { - buf.append('?'); - } else { - if (type == Types.CLOB) { - buf.append(newClobFunction); - } else if (type == Types.BLOB) { - buf.append(newBlobFunction); - } else { - throw new CayenneRuntimeException("Unknown LOB column type: %s(%s). Query buffer: %s." - , type, TypesMapping.getSqlNameByType(type), buf); - } - } - } - - @Override - protected ParameterBinding[] createBindings() { - List<DbAttribute> dbAttributes = query.getDbAttributes(); - int len = dbAttributes.size(); - - ParameterBinding[] bindings = new ParameterBinding[len]; - - for (int i = 0; i < len; i++) { - DbAttribute attribute = dbAttributes.get(i); - bindings[i] = new ParameterBinding(adapter.preferredBindingType(attribute.getType()), attribute.getScale(), attribute); - } - - return bindings; - } - - @Override - protected ParameterBinding[] doUpdateBindings(BatchQueryRow row) { - - int len = bindings.length; - - for (int i = 0, j = 1; i < len; i++) { - - ParameterBinding b = bindings[i]; - - Object value = row.getValue(i); - DbAttribute attribute = b.getAttribute(); - int type = attribute.getType(); - - // TODO: (Andrus) This works as long as there is no LOBs in - // qualifier - if (isUpdateableColumn(value, type)) { - ExtendedType extendedType = value != null - ? adapter.getExtendedTypes().getRegisteredType(value.getClass()) - : adapter.getExtendedTypes().getDefaultType(); - - b.reset(j++, value, extendedType); - } else { - b.disable(); - } - } - - return bindings; - } - - protected boolean isUpdateableColumn(Object value, int type) { - return value == null || type != Types.BLOB && type != Types.CLOB; - } - - void setNewBlobFunction(String string) { - newBlobFunction = string; - } - - void setNewClobFunction(String string) { - newClobFunction = string; - } -} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBInsertBatchTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBInsertBatchTranslator.java deleted file mode 100644 index 2c4b27490..000000000 --- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBInsertBatchTranslator.java +++ /dev/null @@ -1,65 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.dba.oracle; - -import org.apache.cayenne.dba.DbAdapter; -import org.apache.cayenne.dba.QuotingStrategy; -import org.apache.cayenne.map.DbAttribute; -import org.apache.cayenne.query.BatchQueryRow; -import org.apache.cayenne.query.InsertBatchQuery; - -import java.util.Iterator; -import java.util.List; - -class Oracle8LOBInsertBatchTranslator extends Oracle8LOBBatchTranslator { - - Oracle8LOBInsertBatchTranslator(InsertBatchQuery query, DbAdapter adapter, String trimFunction) { - super(query, adapter, trimFunction); - } - - @Override - public String createSql(BatchQueryRow row) { - List<DbAttribute> dbAttributes = query.getDbAttributes(); - - QuotingStrategy strategy = adapter.getQuotingStrategy(); - - StringBuilder buffer = new StringBuilder("INSERT INTO "); - buffer.append(strategy.quotedFullyQualifiedName(query.getDbEntity())); - buffer.append(" ("); - - for (Iterator<DbAttribute> i = dbAttributes.iterator(); i.hasNext();) { - DbAttribute attribute = i.next(); - buffer.append(strategy.quotedName(attribute)); - if (i.hasNext()) { - buffer.append(", "); - } - } - buffer.append(") VALUES ("); - for (int i = 0; i < dbAttributes.size(); i++) { - if (i > 0) { - buffer.append(", "); - } - - appendUpdatedParameter(buffer, dbAttributes.get(i), row.getValue(i)); - } - buffer.append(')'); - return buffer.toString(); - } -} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBUpdateBatchTranslator.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBUpdateBatchTranslator.java deleted file mode 100644 index ffa3f9fef..000000000 --- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8LOBUpdateBatchTranslator.java +++ /dev/null @@ -1,73 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.dba.oracle; - -import org.apache.cayenne.dba.DbAdapter; -import org.apache.cayenne.dba.QuotingStrategy; -import org.apache.cayenne.map.DbAttribute; -import org.apache.cayenne.query.BatchQueryRow; -import org.apache.cayenne.query.UpdateBatchQuery; - -import java.util.Iterator; -import java.util.List; - -class Oracle8LOBUpdateBatchTranslator extends Oracle8LOBBatchTranslator { - - Oracle8LOBUpdateBatchTranslator(UpdateBatchQuery query, DbAdapter adapter, String trimFunction) { - super(query, adapter, trimFunction); - } - - @Override - public String createSql(BatchQueryRow row) { - UpdateBatchQuery updateBatch = (UpdateBatchQuery) query; - List<DbAttribute> idDbAttributes = updateBatch.getQualifierAttributes(); - List<DbAttribute> updatedDbAttributes = updateBatch.getUpdatedAttributes(); - - QuotingStrategy strategy = adapter.getQuotingStrategy(); - - StringBuilder buffer = new StringBuilder("UPDATE "); - buffer.append(strategy.quotedFullyQualifiedName(query.getDbEntity())); - buffer.append(" SET "); - - int len = updatedDbAttributes.size(); - for (int i = 0; i < len; i++) { - if (i > 0) { - buffer.append(", "); - } - - DbAttribute attribute = updatedDbAttributes.get(i); - buffer.append(strategy.quotedName(attribute)); - buffer.append(" = "); - appendUpdatedParameter(buffer, attribute, row.getValue(i)); - } - - buffer.append(" WHERE "); - Iterator<DbAttribute> i = idDbAttributes.iterator(); - while (i.hasNext()) { - DbAttribute attribute = i.next(); - appendDbAttribute(buffer, attribute); - buffer.append(" = ?"); - if (i.hasNext()) { - buffer.append(" AND "); - } - } - return buffer.toString(); - } -} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8SQLTemplateAction.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8SQLTemplateAction.java deleted file mode 100644 index 4999bfc9b..000000000 --- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/Oracle8SQLTemplateAction.java +++ /dev/null @@ -1,88 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.dba.oracle; - -import org.apache.cayenne.access.DataNode; -import org.apache.cayenne.access.OperationObserver; -import org.apache.cayenne.access.translator.sqltemplate.TranslatedSQL; -import org.apache.cayenne.access.jdbc.SQLTemplateAction; -import org.apache.cayenne.query.SQLTemplate; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.Collection; - -/** - * A SQLTemplateAction that addresses Oracle 8 driver limitations. - * - * @since 1.2 - */ -class Oracle8SQLTemplateAction extends SQLTemplateAction { - - Oracle8SQLTemplateAction(SQLTemplate query, DataNode dataNode) { - super(query, dataNode); - } - - /** - * Overrides super implementation to guess whether the query is selecting or - * not and execute it appropriately. Super implementation relied on generic - * JDBC mechanism, common for selecting and updating statements that does - * not work in Oracle 8.* drivers. - */ - @Override - protected void execute(Connection connection, OperationObserver callback, TranslatedSQL compiled, - Collection<Number> updateCounts) throws Exception { - - String sql = compiled.sql().trim(); - boolean select = sql.length() > "SELECT".length() - && sql.substring(0, "SELECT".length()).equalsIgnoreCase("SELECT"); - - long t1 = System.currentTimeMillis(); - boolean iteratedResult = callback.isIteratedResult(); - PreparedStatement statement = connection.prepareStatement(compiled.sql()); - try { - bind(statement, compiled.bindings()); - - // start - code different from super - if (select) { - - ResultSet resultSet = statement.executeQuery(); - try { - processSelectResult(compiled, connection, statement, resultSet, callback, t1); - } finally { - if (!iteratedResult) { - resultSet.close(); - } - } - } else { - int updateCount = statement.executeUpdate(); - updateCounts.add(Integer.valueOf(updateCount)); - dataNode.getJdbcEventLogger().logUpdateCount(updateCount); - } - - // end - code different from super - } finally { - if (!iteratedResult) { - statement.close(); - } - } - } -} diff --git a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleSniffer.java b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleSniffer.java index 68b9dab92..8629fce6c 100644 --- a/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleSniffer.java +++ b/cayenne/src/main/java/org/apache/cayenne/dba/oracle/OracleSniffer.java @@ -45,8 +45,6 @@ public class OracleSniffer implements DbAdapterDetector { return null; } - return md.getDriverMajorVersion() <= 8 - ? objectFactory.newInstance(DbAdapter.class, Oracle8Adapter.class.getName()) - : objectFactory.newInstance(DbAdapter.class, OracleAdapter.class.getName()); + return objectFactory.newInstance(DbAdapter.class, OracleAdapter.class.getName()); } } diff --git a/cayenne/src/main/resources/org/apache/cayenne/dba/oracle/types-oracle8.xml b/cayenne/src/main/resources/org/apache/cayenne/dba/oracle/types-oracle8.xml deleted file mode 100644 index 9ced8dc41..000000000 --- a/cayenne/src/main/resources/org/apache/cayenne/dba/oracle/types-oracle8.xml +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0"?> - -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you under the Apache License, Version 2.0 (the - "License"); you may not use this file except in compliance - with the License. You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, - software distributed under the License is distributed on an - "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - KIND, either express or implied. See the License for the - specific language governing permissions and limitations - under the License. ---> - -<!-- -Oracle 8 types mapping ---> - -<types> - <jdbc-type name="ARRAY"/> - <jdbc-type name="BIGINT"> - <db-type name="NUMBER"/> - </jdbc-type> - <jdbc-type name="BINARY"> - <db-type name="RAW"/> - </jdbc-type> - <jdbc-type name="BIT"> - <db-type name="INTEGER"/> - </jdbc-type> - <jdbc-type name="BLOB"> - <db-type name="BLOB"/> - </jdbc-type> - <jdbc-type name="BOOLEAN"> - <db-type name="INTEGER"/> - </jdbc-type> - <jdbc-type name="CHAR"> - <db-type name="CHAR"/> - </jdbc-type> - <jdbc-type name="CLOB"> - <db-type name="CLOB"/> - </jdbc-type> - <jdbc-type name="DATALINK"/> - <jdbc-type name="DATE"> - <db-type name="DATE"/> - </jdbc-type> - <jdbc-type name="DECIMAL"> - <db-type name="DECIMAL"/> - </jdbc-type> - <jdbc-type name="DOUBLE"> - <db-type name="NUMBER"/> - </jdbc-type> - <jdbc-type name="FLOAT"> - <db-type name="FLOAT"/> - </jdbc-type> - <jdbc-type name="INTEGER"> - <db-type name="INTEGER"/> - </jdbc-type> - <jdbc-type name="JAVA_OBJECT"/> - <jdbc-type name="LONGVARBINARY"> - <db-type name="LONG RAW"/> - </jdbc-type> - <jdbc-type name="LONGVARCHAR"> - <db-type name="LONG VARCHAR"/> - </jdbc-type> - <jdbc-type name="NUMERIC"> - <db-type name="NUMBER"/> - </jdbc-type> - <jdbc-type name="OTHER"/> - <jdbc-type name="REAL"> - <db-type name="NUMBER"/> - </jdbc-type> - <jdbc-type name="REF"/> - <jdbc-type name="SMALLINT"> - <db-type name="SMALLINT"/> - </jdbc-type> - <jdbc-type name="STRUCT"/> - <jdbc-type name="TIME"> - <db-type name="DATE"/> - </jdbc-type> - <jdbc-type name="TIMESTAMP"> - <db-type name="DATE"/> - </jdbc-type> - <jdbc-type name="TINYINT"> - <db-type name="SMALLINT"/> - </jdbc-type> - <jdbc-type name="VARBINARY"> - <db-type name="RAW"/> - </jdbc-type> - <jdbc-type name="VARCHAR"> - <db-type name="VARCHAR"/> - </jdbc-type> -</types> diff --git a/cayenne/src/test/java/org/apache/cayenne/configuration/runtime/DataDomainProviderTest.java b/cayenne/src/test/java/org/apache/cayenne/configuration/runtime/DataDomainProviderTest.java index c8ca8ea06..81c9b61f2 100644 --- a/cayenne/src/test/java/org/apache/cayenne/configuration/runtime/DataDomainProviderTest.java +++ b/cayenne/src/test/java/org/apache/cayenne/configuration/runtime/DataDomainProviderTest.java @@ -76,7 +76,6 @@ import org.apache.cayenne.dba.mariadb.MariaDBSniffer; import org.apache.cayenne.dba.mysql.MySQLAdapter; import org.apache.cayenne.dba.mysql.MySQLPkGenerator; import org.apache.cayenne.dba.mysql.MySQLSniffer; -import org.apache.cayenne.dba.oracle.Oracle8Adapter; import org.apache.cayenne.dba.oracle.OracleAdapter; import org.apache.cayenne.dba.oracle.OraclePkGenerator; import org.apache.cayenne.dba.oracle.OracleSniffer; @@ -194,7 +193,6 @@ public class DataDomainProviderTest { .addPkGenerator(IngresAdapter.class, IngresPkGenerator.class) .addPkGenerator(MySQLAdapter.class, MySQLPkGenerator.class) .addPkGenerator(OracleAdapter.class, OraclePkGenerator.class) - .addPkGenerator(Oracle8Adapter.class, OraclePkGenerator.class) .addPkGenerator(PostgresAdapter.class, PostgresPkGenerator.class) .addPkGenerator(SQLServerAdapter.class, SybasePkGenerator.class) .addPkGenerator(SybaseAdapter.class, SybasePkGenerator.class); diff --git a/cayenne/src/test/java/org/apache/cayenne/dba/oracle/Oracle8AdapterIT.java b/cayenne/src/test/java/org/apache/cayenne/dba/oracle/Oracle8AdapterIT.java deleted file mode 100644 index bbb0957ea..000000000 --- a/cayenne/src/test/java/org/apache/cayenne/dba/oracle/Oracle8AdapterIT.java +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - ****************************************************************/ - -package org.apache.cayenne.dba.oracle; - -import org.apache.cayenne.unit.CayenneProjects; -import org.apache.cayenne.unit.CayenneTestsEnv; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.RegisterExtension; - -import java.net.URL; -import java.sql.Types; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class Oracle8AdapterIT { - - @RegisterExtension - static final CayenneTestsEnv env = CayenneTestsEnv.forProject(CayenneProjects.TESTMAP_PROJECT); - - @Test - public void timestampMapping() throws Exception { - - Oracle8Adapter adapter = env.adhocObjectFactory().newInstance( - Oracle8Adapter.class, - Oracle8Adapter.class.getName()); - - String[] types = adapter.externalTypesForJdbcType(Types.TIMESTAMP); - assertNotNull(types); - assertEquals(1, types.length); - assertEquals("DATE", types[0]); - } - - @Test - public void findAdapterResource() throws Exception { - - Oracle8Adapter adapter = env.adhocObjectFactory().newInstance( - Oracle8Adapter.class, - Oracle8Adapter.class.getName()); - - URL typesURL = adapter.findResource("/types.xml"); - assertNotNull(typesURL); - assertTrue(typesURL.toExternalForm().endsWith("types-oracle8.xml"), - "Unexpected url:" + typesURL); - } -} diff --git a/cayenne/src/test/java/org/apache/cayenne/unit/dba/TestDbAdapter.java b/cayenne/src/test/java/org/apache/cayenne/unit/dba/TestDbAdapter.java index aceb813fc..9e2e4123e 100644 --- a/cayenne/src/test/java/org/apache/cayenne/unit/dba/TestDbAdapter.java +++ b/cayenne/src/test/java/org/apache/cayenne/unit/dba/TestDbAdapter.java @@ -30,7 +30,6 @@ import org.apache.cayenne.dba.h2.H2Adapter; import org.apache.cayenne.dba.hsqldb.HSQLDBAdapter; import org.apache.cayenne.dba.ingres.IngresAdapter; import org.apache.cayenne.dba.mysql.MySQLAdapter; -import org.apache.cayenne.dba.oracle.Oracle8Adapter; import org.apache.cayenne.dba.oracle.OracleAdapter; import org.apache.cayenne.dba.postgres.PostgresAdapter; import org.apache.cayenne.dba.sqlite.SQLiteAdapter; @@ -75,7 +74,6 @@ public abstract class TestDbAdapter { // the order of cases is important due to random adapter subclasses return switch (realAdapter) { case FirebirdAdapter a -> new FirebirdTestDbAdapter(a); - case Oracle8Adapter a -> new OracleTestDbAdapter(a); case OracleAdapter a -> new OracleTestDbAdapter(a); case DerbyAdapter a -> new DerbyTestDbAdapter(a); case SQLServerAdapter a -> new SQLServerTestDbAdapter(a); diff --git a/cayenne/src/test/java/org/apache/cayenne/unit/util/SQLTemplateCustomizer.java b/cayenne/src/test/java/org/apache/cayenne/unit/util/SQLTemplateCustomizer.java index 9233be165..22d5d2004 100644 --- a/cayenne/src/test/java/org/apache/cayenne/unit/util/SQLTemplateCustomizer.java +++ b/cayenne/src/test/java/org/apache/cayenne/unit/util/SQLTemplateCustomizer.java @@ -59,9 +59,6 @@ public class SQLTemplateCustomizer { q3.put( "org.apache.cayenne.dba.oracle.OracleAdapter", "UPDATE ARTIST SET ARTIST_NAME = #bind($newName) WHERE RTRIM(ARTIST_NAME) = #bind($oldName)"); - q3.put( - "org.apache.cayenne.dba.oracle.Oracle8Adapter", - "UPDATE ARTIST SET ARTIST_NAME = #bind($newName) WHERE RTRIM(ARTIST_NAME) = #bind($oldName)"); map.put("SELECT * FROM ARTIST ORDER BY ARTIST_ID", q1); map.put("SELECT * FROM ARTIST WHERE ARTIST_ID = #bind($id)", q2);
