File 0001-Remove-databases-with-missing-dependencies.patch of Package datanucleus-rdbms
--- datanucleus-rdbms-6.0.4/pom.xml 2023-05-12 20:23:47.209323652 +0200
+++ datanucleus-rdbms-6.0.4/pom.xml 2023-05-12 20:23:58.865342133 +0200
@@ -86,26 +86,6 @@
<scope>provided</scope>
</dependency>
- <!-- Required for Oracle support -->
- <dependency>
- <groupId>com.oracle.database.jdbc</groupId>
- <artifactId>ojdbc6</artifactId>
- <version>11.2.0.4</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>com.oracle.database.xml</groupId>
- <artifactId>xdb6</artifactId>
- <version>11.2.0.4</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>com.oracle.database.xml</groupId>
- <artifactId>xmlparserv2</artifactId>
- <version>11.2.0.4</version>
- <optional>true</optional>
- </dependency>
-
<!-- C3P0 -->
<dependency>
<groupId>c3p0</groupId>
@@ -135,21 +115,5 @@
<version>9.0.36</version>
<optional>true</optional>
</dependency>
-
- <!-- BoneCP -->
- <dependency>
- <groupId>com.jolbox</groupId>
- <artifactId>bonecp</artifactId>
- <version>0.8.0.RELEASE</version>
- <optional>true</optional>
- </dependency>
-
- <!-- HikariCP -->
- <dependency>
- <groupId>com.zaxxer</groupId>
- <artifactId>HikariCP</artifactId>
- <version>5.0.1</version>
- <optional>true</optional>
- </dependency>
</dependencies>
</project>
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/adapter/OracleAdapter.java 2023-05-12 20:23:47.221323670 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/adapter/OracleAdapter.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,997 +0,0 @@
-/**********************************************************************
-Copyright (c) 2002 Kelly Grizzle (TJDO) and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-Contributors:
-2002 Mike Martin (TJDO)
-2003 Andy Jefferson - coding standards
-2004 Andy Jefferson - added sequence methods
-2004 Andy Jefferson - updated Oracle version checks to use majorVersion
-2005 Andrew Hoffman - getColumnInfo method to cut down on Oracle startup
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.adapter;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.JDBCType;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Types;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.datanucleus.ClassLoaderResolver;
-import org.datanucleus.exceptions.ClassNotResolvedException;
-import org.datanucleus.exceptions.NucleusDataStoreException;
-import org.datanucleus.exceptions.NucleusException;
-import org.datanucleus.exceptions.NucleusUserException;
-import org.datanucleus.identity.DatastoreId;
-import org.datanucleus.metadata.JdbcType;
-import org.datanucleus.plugin.PluginManager;
-import org.datanucleus.store.StoreManager;
-import org.datanucleus.store.connection.ManagedConnection;
-import org.datanucleus.store.rdbms.mapping.MappingManager;
-import org.datanucleus.store.rdbms.mapping.OracleMappingManagerImpl;
-import org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping;
-import org.datanucleus.store.rdbms.RDBMSPropertyNames;
-import org.datanucleus.store.rdbms.RDBMSStoreManager;
-import org.datanucleus.store.rdbms.identifier.IdentifierFactory;
-import org.datanucleus.store.rdbms.key.PrimaryKey;
-import org.datanucleus.store.rdbms.schema.RDBMSColumnInfo;
-import org.datanucleus.store.rdbms.schema.SQLTypeInfo;
-import org.datanucleus.store.rdbms.sql.SelectStatement;
-import org.datanucleus.store.rdbms.sql.expression.BooleanExpression;
-import org.datanucleus.store.rdbms.sql.expression.CharacterExpression;
-import org.datanucleus.store.rdbms.sql.expression.SQLExpression;
-import org.datanucleus.store.rdbms.sql.method.SQLMethod;
-import org.datanucleus.store.rdbms.sql.operation.SQLOperation;
-import org.datanucleus.store.rdbms.table.Column;
-import org.datanucleus.store.rdbms.table.Table;
-import org.datanucleus.store.schema.StoreSchemaHandler;
-import org.datanucleus.util.Localiser;
-import org.datanucleus.util.NucleusLogger;
-import org.datanucleus.util.StringUtils;
-
-/**
- * Provides methods for adapting SQL language elements to the Oracle database.
- *
- * @see BaseDatastoreAdapter
- */
-public class OracleAdapter extends BaseDatastoreAdapter
-{
- /** What the official Oracle JDBC driver uses to identify itself. */
- public static final String OJDBC_DRIVER_NAME = "Oracle JDBC driver";
-
- /**
- * A string containing the list of Oracle keywords
- * This list is normally obtained dynamically from the driver using
- * DatabaseMetaData.getSQLKeywords()
- *
- * Based on database Oracle8
- */
- public static final String ORACLE_8_RESERVED_WORDS =
- "ACCESS,AUDIT,CLUSTER,COMMENT,COMPRESS,EXCLUSIVE,FILE,IDENTIFIED," +
- "INCREMENT,INDEX,INITIAL,LOCK,LONG,MAXEXTENTS,MINUS,MLSLABEL,MODE," +
- "MODIFY,NOAUDIT,NOCOMPRESS,NOWAIT,NUMBER,OFFLINE,ONLINE,PCTFREE,RAW," +
- "RENAME,RESOURCE,ROWID,ROWNUM,SHARE,SUCCESSFUL,SYNONYM,SYSDATE,UID," +
- "VALIDATE,VARCHAR2,VALIDATE,VARCHAR2";
-
- /**
- * A string containing the list of Oracle keywords
- * This list is normally obtained dynamically from the driver using
- * DatabaseMetaData.getSQLKeywords()
- *
- * Based on database Oracle9i
- */
- public static final String ORACLE_9_RESERVED_WORDS =
- "ACCESS,CHAR,DEFAULT,ADD,CHECK,DELETE,ALL,CLUSTER,DESC,ALTER,COLUMN," +
- "DISTINCT,AND,COMMENT,DROP,ANY,COMPRESS,ELSE,AS,CONNECT,EXCLUSIVE,ASC," +
- "CREATE,EXISTS,AUDIT,CURRENT,FILE,BETWEEN,DATE,FLOAT,BY,DECIMAL,FOR,FROM," +
- "NOT,SHARE,GRANT,NOWAIT,SIZE,GROUP,NULL,SMALLINT,HAVING,NUMBER,START," +
- "IDENTIFIED,OF,SUCCESSFUL,IMMEDIATE,OFFLINE,SYNONYM,IN,ON,SYSDATE," +
- "INCREMENT,ONLINE,TABLE,INDEX,OPTION,THEN,INITIAL,OR,TO,INSERT,ORDER," +
- "TRIGGER,INTEGER,PCTFREE,UID,INTERSECT,PRIOR,UNION,INTO,PRIVILEGES,UNIQUE," +
- "IS,PUBLIC,UPDATE,LEVEL,RAW,USER,LIKE,RENAME,VALIDATE,LOCK,RESOURCE,VALUES," +
- "LONG,REVOKE,VARCHAR,MAXEXTENTS,ROW,VARCHAR2,MINUS,ROWID,VIEW,MLSLABEL," +
- "ROWNUM,WHENEVER,MODE,ROWS,WHERE,MODIFY,SELECT,WITH,NOAUDIT,SESSION," +
- "NOCOMPRESS,SET";
-
- /**
- * A string containing the list of Oracle keywords
- * This list is normally obtained dynamically from the driver using
- * DatabaseMetaData.getSQLKeywords()
- *
- * Based on database Oracle10g
- */
- public static final String ORACLE_10_RESERVED_WORDS =
- "ACCESS,ADD,ALL,ALTER,AND,ANY,AS,ASC,AUDIT,BETWEEN,BY,CHAR,CHECK,CLUSTER," +
- "COLUMN,COMMENT,COMPRESS,CONNECT,CREATE,CURRENT,DATE,DECIMAL,DEFAULT,DELETE," +
- "DESC,DISTINCT,DROP,ELSE,EXCLUSIVE,EXISTS,FILE,FLOAT,FOR,FROM,GRANT,GROUP," +
- "HAVING,IDENTIFIED,IMMEDIATE,IN,INCREMENT,INDEX,INITIAL,INSERT,INTEGER," +
- "INTERSECT,INTO,IS,LEVEL,LIKE,LOCK,LONG,MAXEXTENTS,MINUS,MLSLABEL,MODE," +
- "MODIFY,NOAUDIT,NOCOMPRESS,NOT,NOWAIT,NULL,NUMBER,OF,OFFLINE,ON,ONLINE," +
- "OPTION,OR,ORDER,PCTFREE,PRIOR,PRIVILEGES,PUBLIC,RAW,RENAME,RESOURCE," +
- "REVOKE,ROW,ROWID,ROWNUM,ROWS,SELECT,SESSION,SET,SHARE,SIZE,SMALLINT," +
- "START,SUCCESSFUL,SYNONYM,SYSDATE,TABLE,THEN,TO,TRIGGER,UID,UNION," +
- "UNIQUE,UPDATE,USER,VALIDATE,VALUES,VARCHAR,VARCHAR2,VIEW,WHENEVER," +
- "WHERE,WITH";
-
-
- /**
- * Constructs an Oracle adapter based on the given JDBC metadata.
- * @param metadata the database metadata.
- */
- public OracleAdapter(DatabaseMetaData metadata)
- {
- super(metadata);
-
- if (datastoreMajorVersion <= 8)
- {
- reservedKeywords.addAll(StringUtils.convertCommaSeparatedStringToSet(ORACLE_8_RESERVED_WORDS));
- }
- else if (datastoreMajorVersion == 9)
- {
- reservedKeywords.addAll(StringUtils.convertCommaSeparatedStringToSet(ORACLE_9_RESERVED_WORDS));
- }
- else
- {
- reservedKeywords.addAll(StringUtils.convertCommaSeparatedStringToSet(ORACLE_10_RESERVED_WORDS));
- }
-
- supportedOptions.add(LOCK_ROW_USING_SELECT_FOR_UPDATE);
- supportedOptions.add(LOCK_ROW_USING_SELECT_FOR_UPDATE_NOWAIT);
- supportedOptions.add(SEQUENCES);
- supportedOptions.add(NULL_EQUALS_EMPTY_STRING);
- supportedOptions.add(STORED_PROCEDURES);
- supportedOptions.add(ORDERBY_NULLS_DIRECTIVES);
- supportedOptions.add(GROUP_BY_REQUIRES_ALL_SELECT_PRIMARIES);
- supportedOptions.add(PRIMARYKEY_IN_CREATE_STATEMENTS);
-
- supportedOptions.remove(BOOLEAN_COMPARISON);
- if (datastoreMajorVersion < 9)
- {
- // Oracle 8 doesnt allow "INNER JOIN"
- supportedOptions.remove(ANSI_JOIN_SYNTAX);
- }
- else
- {
- supportedOptions.add(ANSI_JOIN_SYNTAX);
- }
-
- supportedOptions.remove(FK_DELETE_ACTION_DEFAULT);
- supportedOptions.remove(FK_DELETE_ACTION_RESTRICT);
- supportedOptions.remove(FK_UPDATE_ACTION_DEFAULT);
- supportedOptions.remove(FK_UPDATE_ACTION_RESTRICT);
- supportedOptions.remove(FK_UPDATE_ACTION_NULL);
- supportedOptions.remove(FK_UPDATE_ACTION_CASCADE);
-
- if (datastoreMajorVersion >= 12)
- {
- supportedOptions.add(IDENTITY_COLUMNS);
- }
- if ((datastoreMajorVersion == 11 && datastoreMinorVersion >= 2) || datastoreMajorVersion >= 12)
- {
- // In 11.2+ Oracle supports things like "VARCHAR(50 BYTE)"
- supportedOptions.add(COLUMN_LENGTH_SEMANTICS);
- }
- }
-
- /**
- * Initialise the types for this datastore.
- * @param handler SchemaHandler that we initialise the types for
- * @param mconn Managed connection to use
- */
- public void initialiseTypes(StoreSchemaHandler handler, ManagedConnection mconn)
- {
- super.initialiseTypes(handler, mconn);
-
- // Add on any missing JDBC types
- SQLTypeInfo sqlType = new org.datanucleus.store.rdbms.adapter.OracleTypeInfo(
- "CLOB", (short)Types.CLOB, 1073741823, "'", "'", null, 1, true, (short)0, false, false, false, "CLOB", (short)0, (short)0, 10);
- sqlType.setAllowsPrecisionSpec(false); // Can't add precision on a CLOB
- addSQLTypeForJDBCType(handler, mconn, (short)Types.CLOB, sqlType, true);
-
- sqlType = new org.datanucleus.store.rdbms.adapter.OracleTypeInfo(
- "DATE", (short)Types.DATE, 7, null, null, null, 1, false, (short)3, false, false, false, "DATE", (short)0, (short)0, 10);
- addSQLTypeForJDBCType(handler, mconn, (short)Types.DATE, sqlType, true);
-
- sqlType = new org.datanucleus.store.rdbms.adapter.OracleTypeInfo(
- "DECIMAL", (short)Types.DECIMAL, 38, null, null, null, 1, false, (short)3, false, true, false, "NUMBER", (short)-84, (short)127, 10);
- addSQLTypeForJDBCType(handler, mconn, (short)Types.DECIMAL, sqlType, true);
-
- // Oracle has a synonym "DOUBLE PRECISION" (can't specify precision/scale) mapping to sql type of "FLOAT"
- sqlType = new org.datanucleus.store.rdbms.adapter.OracleTypeInfo(
- "DOUBLE PRECISION", (short)Types.DOUBLE, 38, null, null, null, 1, false, (short)3, false, true, false, "NUMBER", (short)-84, (short)127, 10);
- addSQLTypeForJDBCType(handler, mconn, (short)Types.DOUBLE, sqlType, true);
-
- sqlType = new org.datanucleus.store.rdbms.adapter.OracleTypeInfo(
- OracleTypeInfo.TYPES_NAME_SYS_XMLTYPE, (short)OracleTypeInfo.TYPES_SYS_XMLTYPE, 1073741823, "'", "'", null, 1, true, (short)0,
- false, false, false, OracleTypeInfo.TYPES_NAME_SYS_XMLTYPE, (short)0, (short)0, 10);
- addSQLTypeForJDBCType(handler, mconn, (short)OracleTypeInfo.TYPES_SYS_XMLTYPE, sqlType, true);
-
- sqlType = new org.datanucleus.store.rdbms.adapter.OracleTypeInfo(
- "NVARCHAR2", (short)Types.NVARCHAR, 4000, "'", "'", null, 1, true, (short)3, false, false, false, "NVARCHAR2", (short)0, (short)0, 10);
- addSQLTypeForJDBCType(handler, mconn, (short)Types.NVARCHAR, sqlType, true);
-
- // Update any types that need extra info relative to the JDBC info
- Collection<SQLTypeInfo> sqlTypes = getSQLTypeInfoForJdbcType(handler, mconn, (short)Types.BLOB);
- if (sqlTypes != null)
- {
- Iterator<SQLTypeInfo> iter = sqlTypes.iterator();
- while (iter.hasNext())
- {
- sqlType = iter.next();
- sqlType.setAllowsPrecisionSpec(false); // Can't add precision on a BLOB
- }
- }
-
- sqlTypes = getSQLTypeInfoForJdbcType(handler, mconn, (short)Types.CLOB);
- if (sqlTypes != null)
- {
- Iterator<SQLTypeInfo> iter = sqlTypes.iterator();
- while (iter.hasNext())
- {
- sqlType = iter.next();
- sqlType.setAllowsPrecisionSpec(false); // Can't add precision on a CLOB
- }
- }
-
- supportedJdbcTypesById.put(OracleTypeInfo.TYPES_SYS_XMLTYPE, "XMLTYPE");
- }
-
- public SQLTypeInfo newSQLTypeInfo(ResultSet rs)
- {
- return new org.datanucleus.store.rdbms.adapter.OracleTypeInfo(rs);
- }
-
- /**
- * Accessor for a MappingManager suitable for use with this datastore adapter.
- * @param storeMgr The StoreManager
- * @return the MappingManager
- */
- public MappingManager getMappingManager(RDBMSStoreManager storeMgr)
- {
- return new OracleMappingManagerImpl(storeMgr);
- }
-
- /**
- * Accessor for the vendor id
- * @return The Oracle vendor id
- */
- public String getVendorID()
- {
- return "oracle";
- }
-
- /**
- * Some databases, Oracle, treats an empty string (0 length) equals null
- * @return returns a surrogate to replace the empty string in the database
- * otherwise it would be treated as null
- */
- public String getSurrogateForEmptyStrings()
- {
- return "\u0001";
- }
-
- /**
- * @return null, because oracle does not have catalogs
- */
- public String getCatalogName(Connection conn) throws SQLException
- {
- return null;
- }
-
- public String getSchemaName(Connection conn) throws SQLException
- {
- Statement stmt = conn.createStatement();
-
- try
- {
- String stmtText = "SELECT SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') FROM DUAL";
- ResultSet rs = stmt.executeQuery(stmtText);
-
- try
- {
- if (!rs.next())
- {
- throw new NucleusDataStoreException("No result returned from " + stmtText).setFatal();
- }
-
- return rs.getString(1);
- }
- finally
- {
- rs.close();
- }
- }
- finally
- {
- stmt.close();
- }
- }
-
- public String getCreateDatabaseStatement(String catalogName, String schemaName)
- {
- throw new UnsupportedOperationException("Oracle does not support CREATE SCHEMA; you need to create a USER (manually)");
- }
-
- public String getDropDatabaseStatement(String catalogName, String schemaName)
- {
- throw new UnsupportedOperationException("Oracle does not support DROP SCHEMA; you need to delete a USER (manually)");
- }
-
- public String getAddPrimaryKeyStatement(PrimaryKey pk, IdentifierFactory factory)
- {
- // We are using PRIMARYKEY_IN_CREATE_STATEMENTS so return null
- return null;
- }
-
- /**
- * Provide the existing indexes in the database for the table.
- * This is implemented if and only if the datastore has its own way of getting indexes.
- * In this implementation we provide an alternate method for Oracle JDBC driver < 10.2.0.1.0 only.
- * All other versions of Oracle will use the default. The schemaName MUST BE PROVIDED.
- * @param conn the JDBC connection
- * @param catalog the catalog name
- * @param schema the schema name.
- * @param table the table name
- * @return a ResultSet with the format @see DatabaseMetaData#getIndexInfo(java.lang.String, java.lang.String, java.lang.String, boolean, boolean)
- * @throws SQLException if an error occurs
- */
- public ResultSet getExistingIndexes(Connection conn, String catalog, String schema, String table)
- throws SQLException
- {
- if (isReservedKeyword(table) || !table.matches("[a-zA-Z]{1}\\w*(\\$|\\#)*\\w*"))
- {
- // THIS IS A FIX for the JDBC driver. Already noticed in previous versions, but this fix was
- // only tested with Oracle 10g, and all drivers versions. Occurs when the table identifier is
- // a reserved word or doesn't match the regexp defined above
- String GET_INDEXES_STMT =
- "SELECT null as table_cat, "+
- "owner as table_schem, "+
- "table_name, "+
- "0 as NON_UNIQUE, "+
- "null as index_qualifier, "+
- "null as index_name, 0 as type, "+
- "0 as ordinal_position, null as column_name, "+
- "null as asc_or_desc, "+
- "num_rows as cardinality, "+
- "blocks as pages, "+
- "null as filter_condition "+
- "FROM all_tables "+
- "WHERE table_name = ? "+
- "AND owner = ? "+
-
- "UNION "+
-
- "SELECT null as table_cat, "+
- "i.owner as table_schem, "+
- "i.table_name, "+
- "decode (i.uniqueness, 'UNIQUE', 0, 1), "+
- "null as index_qualifier, "+
- "i.index_name, "+
- "1 as type, "+
- "c.column_position as ordinal_position, "+
- "c.column_name, "+
- "null as asc_or_desc, "+
- "i.distinct_keys as cardinality, "+
- "i.leaf_blocks as pages, "+
- "null as filter_condition "+
- "FROM all_indexes i, all_ind_columns c "+
- "WHERE i.table_name = ? "+
- "AND i.owner = ? "+
- "AND i.index_name = c.index_name "+
- "AND i.table_owner = c.table_owner "+
- "AND i.table_name = c.table_name "+
- "AND i.owner = c.index_owner "+
- "ORDER BY non_unique, type, index_name, ordinal_position";
-
- NucleusLogger.DATASTORE_SCHEMA.debug("Retrieving Oracle index info using the following SQL : " + GET_INDEXES_STMT);
- PreparedStatement stmt = conn.prepareStatement(GET_INDEXES_STMT);
- stmt.setString(1,table);
- stmt.setString(2,schema);
- stmt.setString(3,table);
- stmt.setString(4,schema);
- return stmt.executeQuery();
- }
-
- return super.getExistingIndexes(conn,catalog,schema,table);
- }
-
- /**
- * Method to return the drop table statement for Oracle.
- * @param table The table
- * @return The statement text
- */
- public String getDropTableStatement(Table table)
- {
- if (datastoreMajorVersion >= 10)
- {
- // Add "PURGE" to avoid putting the table into the Oracle "recycle bin"
- return "DROP TABLE " + table.toString() + " CASCADE CONSTRAINTS PURGE";
- }
- return "DROP TABLE " + table.toString() + " CASCADE CONSTRAINTS";
- }
-
- /**
- * Accessor for the auto-increment sql statement for getting the last value for this table.
- * @param table Name of the table that the autoincrement is for
- * @param columnName Name of the column that the autoincrement is for
- * @return The statement for getting the latest auto-increment key
- */
- /*public String getIdentityLastValueStmt(Table table, String columnName)
- {
- // Oracle 12 doesnt seem to provide a mechanism for getting the identity value, so assume JDBC getGeneratedKeys works
- return "VALUES IDENTITY_VAL_LOCAL()";
- }*/
-
- /**
- * Accessor for the auto-increment keyword for generating DDLs (CREATE TABLEs...).
- * @param storeMgr The Store Manager
- * @return The keyword for a column using auto-increment
- */
- public String getIdentityKeyword(StoreManager storeMgr)
- {
- // Oracle 12+
- return "generated always as identity";
- }
-
- /**
- * Accessor for the sequence statement to create the sequence.
- * @param sequenceName Name of the sequence
- * @param min Minimum value for the sequence
- * @param max Maximum value for the sequence
- * @param start Start value for the sequence
- * @param increment Increment value for the sequence
- * @param cacheSize Cache size for the sequence
- * @return The statement for getting the next id from the sequence
- */
- public String getSequenceCreateStmt(String sequenceName, Integer min, Integer max, Integer start, Integer increment, Integer cacheSize)
- {
- if (sequenceName == null)
- {
- throw new NucleusUserException(Localiser.msg("051028"));
- }
-
- StringBuilder stmt = new StringBuilder("CREATE SEQUENCE ");
- stmt.append(sequenceName);
- if (min != null)
- {
- stmt.append(" MINVALUE " + min);
- }
- if (max != null)
- {
- stmt.append(" MAXVALUE " + max);
- }
- if (start != null)
- {
- stmt.append(" START WITH " + start);
- }
- if (increment != null)
- {
- stmt.append(" INCREMENT BY " + increment);
- }
- if (cacheSize != null)
- {
- stmt.append(" CACHE " + cacheSize);
- }
- else
- {
- stmt.append(" NOCACHE");
- }
-
- return stmt.toString();
- }
-
- /**
- * Accessor for the statement for getting the next id from the sequence for this datastore.
- * @param sequenceName Name of the sequence
- * @return The statement for getting the next id for the sequence
- **/
- public String getSequenceNextStmt(String sequenceName)
- {
- if (sequenceName == null)
- {
- throw new NucleusUserException(Localiser.msg("051028"));
- }
- StringBuilder stmt=new StringBuilder("SELECT ");
- stmt.append(sequenceName);
- stmt.append(".NEXTVAL from dual ");
-
- return stmt.toString();
- }
-
- /**
- * Method to create a column info for the current row.
- * Overrides the dataType to cater for Oracle particularities.
- * @param rs ResultSet from DatabaseMetaData.getColumns()
- * @return column info
- */
- public RDBMSColumnInfo newRDBMSColumnInfo(ResultSet rs)
- {
- RDBMSColumnInfo info = new RDBMSColumnInfo(rs);
- String typeName = info.getTypeName();
- int dataType = -1;
- if (typeName == null)
- {
- dataType = Types.NULL;
- }
- else if (typeName.equals("ROWID"))
- {
- dataType = Types.INTEGER;
- }
- else if (typeName.equals("NUMBER") || typeName.equals("VARNUM"))
- {
- dataType = Types.NUMERIC;
- }
- else if (typeName.equals("VARCHAR2"))
- {
- dataType = Types.VARCHAR;
- }
- else if (typeName.equals("CHAR"))
- {
- dataType = Types.CHAR;
- }
- else if (typeName.equals("DATE"))
- {
- // should this be TIMESTAMP instead of DATE ??
- dataType = Types.DATE;
- }
- else if (typeName.equals("CLOB") || typeName.equals("NCLOB"))
- {
- dataType = Types.CLOB;
- }
- else if (typeName.equals("BLOB"))
- {
- dataType = Types.BLOB;
- }
- else if (typeName.equals("LONG"))
- {
- dataType = Types.LONGVARCHAR;
- }
- else if (typeName.equals("LONG RAW"))
- {
- dataType = Types.LONGVARBINARY;
- }
- else if (typeName.equals("RAW"))
- {
- dataType = Types.VARBINARY;
- }
- else if (typeName.startsWith("TIMESTAMP"))
- {
- dataType = Types.TIMESTAMP;
- }
- else if (typeName.equals("FLOAT"))
- {
- dataType = Types.FLOAT;
- }
- else
- {
- NucleusLogger.DATASTORE.warn(Localiser.msg("020191", typeName));
- dataType = Types.OTHER;
- }
-
- info.setDataType((short)dataType);
-
- return info;
- }
-
- /**
- * Accessor for the transaction isolation level to use during schema creation.
- * @return The transaction isolation level for schema generation process
- */
- public int getTransactionIsolationForSchemaCreation()
- {
- return Connection.TRANSACTION_READ_COMMITTED;
- }
-
- /**
- * Accessor for table and column information for a catalog/schema in this datastore.
- * An override for the DatabaseMetaData.getColumns() method call as referenced in superclass.
- * The default Oracle-provided getColumns() method is VERY slow for large schemas,
- * particularly due to REMARKS and COLUMN_DEF (column defaults) columns
- * (outer-joins in data dictionary views)
- * <b>Note:</b> This method DOES NOT return default column value (meta-data ResultSet column COLUMN_DEF)
- * as this column causes MAJOR slowdown in meta-data retrieval performance.
- * @param conn Connection to use
- * @param catalog The catalog (null if none)
- * @param schema The schema (null if none)
- * @param table The table (null if all)
- * @param columnNamePattern Col name(s) (null if all) NOT USED
- * @return ResultSet containing the table/column information
- * @throws SQLException Thrown if an error occurs
- */
- public ResultSet getColumns(Connection conn, String catalog, String schema, String table, String columnNamePattern)
- throws SQLException
- {
- // setup SQL for query from Oracle data dictionary view ALL_TAB_COLUMNS
- StringBuilder columnsQuery = new StringBuilder();
- columnsQuery.append("SELECT NULL TABLE_CAT, OWNER TABLE_SCHEM, TABLE_NAME, COLUMN_NAME, NULL DATA_TYPE, ");
- columnsQuery.append("DATA_TYPE TYPE_NAME, DECODE(DATA_TYPE,'NUMBER',DATA_PRECISION,DATA_LENGTH) COLUMN_SIZE, ");
- columnsQuery.append("0 BUFFER_LENGTH, DATA_SCALE DECIMAL_DIGITS, 10 NUM_PREC_RADIX, ");
- columnsQuery.append("DECODE(NULLABLE,'Y',1,0) NULLABLE, NULL REMARKS, NULL COLUMN_DEF, 0 SQL_DATA_TYPE, 0 SQL_DATETIME_SUB, ");
- columnsQuery.append("DATA_LENGTH CHAR_OCTET_LENGTH, COLUMN_ID ORDINAL_POSITION, DECODE(NULLABLE,'Y','YES','NO') IS_NULLABLE ");
- columnsQuery.append("FROM ALL_TAB_COLUMNS ");
-
- boolean outputWhere = false;
- if (schema != null && schema.length() > 0)
- {
- // where clause - schemaString
- columnsQuery.append("WHERE OWNER LIKE '").append(schema).append("' ");
- outputWhere = true;
- }
- if (table != null)
- {
- // where clause - tableString
- if (!outputWhere)
- {
- columnsQuery.append("WHERE ");
- outputWhere = true;
- }
- else
- {
- columnsQuery.append("AND ");
- }
-
- if (table.length() > 0)
- {
- columnsQuery.append("TABLE_NAME LIKE '").append(table).append("' ");
- }
- else
- {
- columnsQuery.append("TABLE_NAME IS NULL ");
- }
- }
-
- // TODO Support columnNamePattern
-
- columnsQuery.append("ORDER BY TABLE_SCHEM, TABLE_NAME, ORDINAL_POSITION ");
- NucleusLogger.DATASTORE_SCHEMA.debug("Retrieving Oracle column info using the following SQL : " + columnsQuery);
-
- PreparedStatement columnsStmt = conn.prepareStatement(columnsQuery.toString());
- ResultSet columnsResult = columnsStmt.executeQuery();
-
- columnsQuery = null;
- return columnsResult;
- }
-
- /**
- * Accessor for a statement that will return the statement to use to get the datastore date.
- * @return SQL statement to get the datastore date
- */
- public String getDatastoreDateStatement()
- {
- return "SELECT CURRENT_TIMESTAMP FROM DUAL";
- }
-
- /**
- * Convenience method to allow adaption of an ordering string before applying it.
- * This is useful where the datastore accepts some conversion adapter around the ordering column
- * for example.
- * @param storeMgr StoreManager
- * @param orderString The basic ordering string
- * @param sqlExpr The sql expression being represented here
- * @return The adapted ordering string
- */
- public String getOrderString(StoreManager storeMgr, String orderString, SQLExpression sqlExpr)
- {
- String nlsSortOrder = "LATIN";
- String sortOrder = storeMgr.getStringProperty(RDBMSPropertyNames.PROPERTY_RDBMS_ORACLE_NLS_SORT_ORDER);
- if (sortOrder != null)
- {
- nlsSortOrder = sortOrder.toUpperCase();
- }
-
- if (sqlExpr instanceof CharacterExpression && !nlsSortOrder.equals("BINARY"))
- {
- // Wrap with NLSSORT function
- return "NLSSORT(" + orderString + ", 'NLS_SORT = " + nlsSortOrder + "')";
- }
- else if (datastoreMajorVersion < 9 && sqlExpr instanceof BooleanExpression &&
- !sqlExpr.getJavaTypeMapping().getColumnMapping(0).isStringBased())
- {
- // Oracle 8 or earlier don't support ORDER BY on non-String based booleans ? (came from TJDO)
- throw new NucleusException(Localiser.msg("052505")).setFatal();
- }
- else
- {
- return orderString;
- }
- }
-
- /* (non-Javadoc)
- * @see org.datanucleus.store.rdbms.adapter.DatabaseAdapter#isStatementTimeout(java.sql.SQLException)
- */
- @Override
- public boolean isStatementTimeout(SQLException sqle)
- {
- if (sqle.getSQLState() != null && sqle.getSQLState().equalsIgnoreCase("72000") && sqle.getErrorCode() == 1013)
- {
- return true;
- }
-
- return super.isStatementTimeout(sqle);
- }
-
- /**
- * Method to return if it is valid to select the specified mapping for the specified statement
- * for this datastore adapter. Sometimes, dependent on the type of the column(s), and what other
- * components are present in the statement, it may be invalid to select the mapping.
- * This implementation returns true, so override in database-specific subclass as required.
- * @param stmt The statement
- * @param m The mapping that we want to select
- * @return Whether it is valid
- */
- public boolean validToSelectMappingInStatement(SelectStatement stmt, JavaTypeMapping m)
- {
- if (m.getNumberOfColumnMappings() <= 0)
- {
- return true;
- }
-
- for (int i=0;i<m.getNumberOfColumnMappings();i++)
- {
- Column col = m.getColumnMapping(i).getColumn();
- if (col.getJdbcType() == JdbcType.CLOB || col.getJdbcType() == JdbcType.BLOB)
- {
- // "java.sql.SQLException: ORA-00932: inconsistent datatypes: expected - got CLOB"
- if (stmt.isDistinct())
- {
- NucleusLogger.QUERY.debug("Not selecting " + m + " since is for BLOB/CLOB and using DISTINCT");
- return false;
- }
- }
- }
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.datanucleus.store.rdbms.adapter.DatabaseAdapter#getRangeByRowNumberColumn2()
- */
- public String getRangeByRowNumberColumn2()
- {
- return "ROWNUM";
- }
-
- /* (non-Javadoc)
- * @see org.datanucleus.store.rdbms.adapter.BaseDatastoreAdapter#getSQLOperationClass(java.lang.String)
- */
- @Override
- public Class<? extends SQLOperation> getSQLOperationClass(String operationName)
- {
- if ("mod".equals(operationName)) return org.datanucleus.store.rdbms.sql.operation.Mod2Operation.class;
-
- return super.getSQLOperationClass(operationName);
- }
-
- /* (non-Javadoc)
- * @see org.datanucleus.store.rdbms.adapter.BaseDatastoreAdapter#getSQLMethodClass(java.lang.String, java.lang.String)
- */
- @Override
- public Class<? extends SQLMethod> getSQLMethodClass(String className, String methodName, ClassLoaderResolver clr)
- {
- if (className == null)
- {
- if ("YEAR".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalYearMethod2.class;
- else if ("MONTH".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMonthMethod2.class;
- else if ("MONTH_JAVA".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMonthJavaMethod2.class;
- else if ("DAY".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalDayMethod2.class;
- else if ("HOUR".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalHourMethod2.class;
- else if ("MINUTE".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMinuteMethod2.class;
- else if ("SECOND".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalSecondMethod2.class;
- else if ("WEEK".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalWeekMethod6.class;
- else if ("QUARTER".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalQuarterMethod2.class;
-
- else if ("SQL_cube".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.SQLCubeFunction.class;
- else if ("SQL_rollup".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.SQLRollupFunction.class;
- }
- else
- {
- Class cls = null;
- try
- {
- cls = clr.classForName(className);
- }
- catch (ClassNotResolvedException cnre) {}
-
- if ("java.lang.String".equals(className))
- {
- if ("concat".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.StringConcat1Method.class;
- else if ("indexOf".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.StringIndexOf2Method.class;
- else if ("length".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.StringLength3Method.class;
- else if ("substring".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.StringSubstring3Method.class;
- else if ("translate".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.StringTranslateMethod.class;
- }
- else if ("java.util.Date".equals(className) || (cls != null && java.util.Date.class.isAssignableFrom(cls)))
- {
- if ("getDay".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalDayMethod2.class;
- else if ("getDate".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalDayMethod2.class;
- else if ("getMonth".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMonthJavaMethod2.class;
- else if ("getYear".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalYearMethod2.class;
- else if ("getHour".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalHourMethod2.class;
- else if ("getMinute".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMinuteMethod2.class;
- else if ("getSecond".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalSecondMethod2.class;
- }
- else if ("java.time.LocalTime".equals(className))
- {
- if ("getHour".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalHourMethod2.class;
- else if ("getMinute".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMinuteMethod2.class;
- else if ("getSecond".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalSecondMethod2.class;
- }
- else if ("java.time.LocalDate".equals(className))
- {
- if ("getDayOfMonth".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalDayMethod2.class;
- else if ("getMonthValue".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMonthMethod2.class;
- else if ("getYear".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalYearMethod2.class;
- }
- else if ("java.time.LocalDateTime".equals(className))
- {
- if ("getDayOfMonth".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalDayMethod2.class;
- else if ("getMonthValue".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMonthMethod2.class;
- else if ("getYear".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalYearMethod2.class;
- else if ("getHour".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalHourMethod2.class;
- else if ("getMinute".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMinuteMethod2.class;
- else if ("getSecond".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalSecondMethod2.class;
- }
- else if ("java.time.MonthDay".equals(className))
- {
- if ("getDayOfMonth".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalDayMethod2.class;
- else if ("getMonthValue".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMonthMethod2.class;
- }
- else if ("java.time.Period".equals(className))
- {
- if ("getMonths".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMonthMethod2.class;
- else if ("getDays".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalDayMethod2.class;
- else if ("getYears".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalYearMethod2.class;
- }
- else if ("java.time.YearMonth".equals(className))
- {
- if ("getMonthValue".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalMonthMethod2.class;
- else if ("getYear".equals(methodName)) return org.datanucleus.store.rdbms.sql.method.TemporalYearMethod2.class;
- }
- }
-
- return super.getSQLMethodClass(className, methodName, clr);
- }
-
- @Override
- public String getInsertStatementForNoColumns(Table table)
- {
- return "INSERT INTO " + table.toString() + " VALUES (DEFAULT)";
- }
-
- /**
- * Load all datastore mappings for this RDBMS database.
- * @param mgr the PluginManager
- * @param clr the ClassLoaderResolver
- */
- protected void loadColumnMappings(PluginManager mgr, ClassLoaderResolver clr)
- {
- // Load up built-in types for this datastore
- registerColumnMapping(Boolean.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", true);
- registerColumnMapping(Boolean.class.getName(), org.datanucleus.store.rdbms.mapping.column.BitColumnMapping.class, JDBCType.BIT, "BIT", false);
- registerColumnMapping(Boolean.class.getName(), org.datanucleus.store.rdbms.mapping.column.CharColumnMapping.class, JDBCType.CHAR, "CHAR", false);
- registerColumnMapping(Boolean.class.getName(), org.datanucleus.store.rdbms.mapping.column.BooleanColumnMapping.class, JDBCType.BOOLEAN, "BOOLEAN", false);
- registerColumnMapping(Boolean.class.getName(), org.datanucleus.store.rdbms.mapping.column.BooleanColumnMapping.class, JDBCType.TINYINT, "TINYINT", false);
- registerColumnMapping(Boolean.class.getName(), org.datanucleus.store.rdbms.mapping.column.SmallIntColumnMapping.class, JDBCType.SMALLINT, "SMALLINT", false);
-
- registerColumnMapping(Byte.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", true);
- registerColumnMapping(Byte.class.getName(), org.datanucleus.store.rdbms.mapping.column.TinyIntColumnMapping.class, JDBCType.TINYINT, "TINYINT", false);
- registerColumnMapping(Byte.class.getName(), org.datanucleus.store.rdbms.mapping.column.SmallIntColumnMapping.class, JDBCType.SMALLINT, "SMALLINT", false);
-
- registerColumnMapping(Character.class.getName(), org.datanucleus.store.rdbms.mapping.column.CharColumnMapping.class, JDBCType.CHAR, "CHAR", true);
- registerColumnMapping(Character.class.getName(), org.datanucleus.store.rdbms.mapping.column.IntegerColumnMapping.class, JDBCType.INTEGER, "INTEGER", false);
- registerColumnMapping(Character.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", false);
-
- registerColumnMapping(Double.class.getName(), org.datanucleus.store.rdbms.mapping.column.FloatColumnMapping.class, JDBCType.FLOAT, "FLOAT", true);
- registerColumnMapping(Double.class.getName(), org.datanucleus.store.rdbms.mapping.column.DoubleColumnMapping.class, JDBCType.DOUBLE, "DOUBLE", false);
- registerColumnMapping(Double.class.getName(), org.datanucleus.store.rdbms.mapping.column.DecimalColumnMapping.class, JDBCType.DECIMAL, "DECIMAL", false);
- registerColumnMapping(Double.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", false);
-
- registerColumnMapping(Float.class.getName(), org.datanucleus.store.rdbms.mapping.column.FloatColumnMapping.class, JDBCType.FLOAT, "FLOAT", true);
- registerColumnMapping(Float.class.getName(), org.datanucleus.store.rdbms.mapping.column.DoubleColumnMapping.class, JDBCType.DOUBLE, "DOUBLE", false);
- registerColumnMapping(Float.class.getName(), org.datanucleus.store.rdbms.mapping.column.RealColumnMapping.class, JDBCType.REAL, "REAL", false);
- registerColumnMapping(Float.class.getName(), org.datanucleus.store.rdbms.mapping.column.DecimalColumnMapping.class, JDBCType.DECIMAL, "DECIMAL", false);
- registerColumnMapping(Float.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", false);
-
- registerColumnMapping(Integer.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", true);
- registerColumnMapping(Integer.class.getName(), org.datanucleus.store.rdbms.mapping.column.IntegerColumnMapping.class, JDBCType.INTEGER, "INTEGER", false);
- registerColumnMapping(Integer.class.getName(), org.datanucleus.store.rdbms.mapping.column.BigIntColumnMapping.class, JDBCType.BIGINT, "BIGINT", false);
- registerColumnMapping(Integer.class.getName(), org.datanucleus.store.rdbms.mapping.column.TinyIntColumnMapping.class, JDBCType.TINYINT, "TINYINT", false);
- registerColumnMapping(Integer.class.getName(), org.datanucleus.store.rdbms.mapping.column.SmallIntColumnMapping.class, JDBCType.SMALLINT, "SMALLINT", false);
-
- registerColumnMapping(Long.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", true);
- registerColumnMapping(Long.class.getName(), org.datanucleus.store.rdbms.mapping.column.BigIntColumnMapping.class, JDBCType.BIGINT, "BIGINT", false);
- registerColumnMapping(Long.class.getName(), org.datanucleus.store.rdbms.mapping.column.IntegerColumnMapping.class, JDBCType.INTEGER, "INT", false);
- registerColumnMapping(Long.class.getName(), org.datanucleus.store.rdbms.mapping.column.TinyIntColumnMapping.class, JDBCType.TINYINT, "TINYINT", false);
- registerColumnMapping(Long.class.getName(), org.datanucleus.store.rdbms.mapping.column.SmallIntColumnMapping.class, JDBCType.SMALLINT, "SMALLINT", false);
-
- registerColumnMapping(Short.class.getName(), org.datanucleus.store.rdbms.mapping.column.SmallIntColumnMapping.class, JDBCType.SMALLINT, "SMALLINT", true);
- registerColumnMapping(Short.class.getName(), org.datanucleus.store.rdbms.mapping.column.IntegerColumnMapping.class, JDBCType.INTEGER, "INTEGER", false);
- registerColumnMapping(Short.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", false);
- registerColumnMapping(Short.class.getName(), org.datanucleus.store.rdbms.mapping.column.TinyIntColumnMapping.class, JDBCType.TINYINT, "TINYINT", false);
-
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.VarCharColumnMapping.class, JDBCType.VARCHAR, "VARCHAR", true);
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.CharColumnMapping.class, JDBCType.CHAR, "CHAR", false);
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.BigIntColumnMapping.class, JDBCType.BIGINT, "BIGINT", false);
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.LongVarcharColumnMapping.class, JDBCType.LONGVARCHAR, "LONGVARCHAR", false);
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.OracleClobColumnMapping.class, JDBCType.CLOB, "CLOB", false);
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.OracleBlobColumnMapping.class, JDBCType.BLOB, "BLOB", false);
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.OracleXMLTypeColumnMapping.class, "XMLTYPE", "XMLTYPE", false);
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.NVarcharColumnMapping.class, JDBCType.NVARCHAR, "NVARCHAR", false);
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.NCharColumnMapping.class, JDBCType.NCHAR, "NCHAR", false);
- registerColumnMapping(String.class.getName(), org.datanucleus.store.rdbms.mapping.column.NVarcharColumnMapping.class, JDBCType.NVARCHAR, "NVARCHAR2", false);
-
- registerColumnMapping(BigDecimal.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", true);
- registerColumnMapping(BigDecimal.class.getName(), org.datanucleus.store.rdbms.mapping.column.DecimalColumnMapping.class, JDBCType.DECIMAL, "DECIMAL", false);
-
- registerColumnMapping(BigInteger.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", true);
- registerColumnMapping(BigInteger.class.getName(), org.datanucleus.store.rdbms.mapping.column.BigIntColumnMapping.class, JDBCType.BIGINT, "BIGINT", false);
-
- registerColumnMapping(java.sql.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.DateColumnMapping.class, JDBCType.DATE, "DATE", true);
- registerColumnMapping(java.sql.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.TimestampColumnMapping.class, JDBCType.TIMESTAMP, "TIMESTAMP", false);
- registerColumnMapping(java.sql.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.CharColumnMapping.class, JDBCType.CHAR, "CHAR", false);
- registerColumnMapping(java.sql.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.VarCharColumnMapping.class, JDBCType.VARCHAR, "VARCHAR", false);
- registerColumnMapping(java.sql.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.BigIntColumnMapping.class, JDBCType.BIGINT, "BIGINT", false);
-
- registerColumnMapping(java.sql.Time.class.getName(), org.datanucleus.store.rdbms.mapping.column.TimeColumnMapping.class, JDBCType.TIME, "TIME", true);
- registerColumnMapping(java.sql.Time.class.getName(), org.datanucleus.store.rdbms.mapping.column.TimestampColumnMapping.class, JDBCType.TIMESTAMP, "TIMESTAMP", false);
- registerColumnMapping(java.sql.Time.class.getName(), org.datanucleus.store.rdbms.mapping.column.CharColumnMapping.class, JDBCType.CHAR, "CHAR", false);
- registerColumnMapping(java.sql.Time.class.getName(), org.datanucleus.store.rdbms.mapping.column.VarCharColumnMapping.class, JDBCType.VARCHAR, "VARCHAR", false);
- registerColumnMapping(java.sql.Time.class.getName(), org.datanucleus.store.rdbms.mapping.column.BigIntColumnMapping.class, JDBCType.BIGINT, "BIGINT", false);
-
- registerColumnMapping(java.sql.Timestamp.class.getName(), org.datanucleus.store.rdbms.mapping.column.TimestampColumnMapping.class, JDBCType.TIMESTAMP, "TIMESTAMP", true);
- registerColumnMapping(java.sql.Timestamp.class.getName(), org.datanucleus.store.rdbms.mapping.column.CharColumnMapping.class, JDBCType.CHAR, "CHAR", false);
- registerColumnMapping(java.sql.Timestamp.class.getName(), org.datanucleus.store.rdbms.mapping.column.VarCharColumnMapping.class, JDBCType.VARCHAR, "VARCHAR", false);
- registerColumnMapping(java.sql.Timestamp.class.getName(), org.datanucleus.store.rdbms.mapping.column.DateColumnMapping.class, JDBCType.DATE, "DATE", false);
- registerColumnMapping(java.sql.Timestamp.class.getName(), org.datanucleus.store.rdbms.mapping.column.TimeColumnMapping.class, JDBCType.TIME, "TIME", false);
-
- registerColumnMapping(java.util.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.TimestampColumnMapping.class, JDBCType.TIMESTAMP, "TIMESTAMP", true);
- registerColumnMapping(java.util.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.DateColumnMapping.class, JDBCType.DATE, "DATE", false);
- registerColumnMapping(java.util.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.CharColumnMapping.class, JDBCType.CHAR, "CHAR", false);
- registerColumnMapping(java.util.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.VarCharColumnMapping.class, JDBCType.VARCHAR, "VARCHAR", false);
- registerColumnMapping(java.util.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.TimeColumnMapping.class, JDBCType.TIME, "TIME", false);
- registerColumnMapping(java.util.Date.class.getName(), org.datanucleus.store.rdbms.mapping.column.BigIntColumnMapping.class, JDBCType.BIGINT, "BIGINT", false);
-
- registerColumnMapping(java.io.Serializable.class.getName(), org.datanucleus.store.rdbms.mapping.column.OracleBlobColumnMapping.class, JDBCType.BLOB, "BLOB", true);
- registerColumnMapping(java.io.Serializable.class.getName(), org.datanucleus.store.rdbms.mapping.column.LongVarBinaryColumnMapping.class, JDBCType.LONGVARBINARY, "LONGVARBINARY", false);
- registerColumnMapping(java.io.Serializable.class.getName(), org.datanucleus.store.rdbms.mapping.column.LongVarBinaryColumnMapping.class, JDBCType.LONGVARBINARY, "LONG RAW", false);
- registerColumnMapping(java.io.Serializable.class.getName(), org.datanucleus.store.rdbms.mapping.column.VarBinaryColumnMapping.class, JDBCType.VARBINARY, "VARBINARY", false);
- registerColumnMapping(java.io.Serializable.class.getName(), org.datanucleus.store.rdbms.mapping.column.VarBinaryColumnMapping.class, JDBCType.VARBINARY, "RAW", false);
- registerColumnMapping(java.io.Serializable.class.getName(), org.datanucleus.store.rdbms.mapping.column.BinaryColumnMapping.class, JDBCType.BINARY, "BINARY", false);
- registerColumnMapping(java.io.Serializable.class.getName(), org.datanucleus.store.rdbms.mapping.column.BinaryColumnMapping.class, JDBCType.BINARY, "RAW", false);
-
- registerColumnMapping(byte[].class.getName(), org.datanucleus.store.rdbms.mapping.column.OracleBlobColumnMapping.class, JDBCType.BLOB, "BLOB", true);
- registerColumnMapping(byte[].class.getName(), org.datanucleus.store.rdbms.mapping.column.LongVarBinaryColumnMapping.class, JDBCType.LONGVARBINARY, "LONGVARBINARY", false);
- registerColumnMapping(byte[].class.getName(), org.datanucleus.store.rdbms.mapping.column.LongVarBinaryColumnMapping.class, JDBCType.LONGVARBINARY, "LONG RAW", false);
- registerColumnMapping(byte[].class.getName(), org.datanucleus.store.rdbms.mapping.column.VarBinaryColumnMapping.class, JDBCType.VARBINARY, "VARBINARY", false);
- registerColumnMapping(byte[].class.getName(), org.datanucleus.store.rdbms.mapping.column.VarBinaryColumnMapping.class, JDBCType.VARBINARY, "RAW", false);
- registerColumnMapping(byte[].class.getName(), org.datanucleus.store.rdbms.mapping.column.BinaryColumnMapping.class, JDBCType.BINARY, "BINARY", false);
- registerColumnMapping(byte[].class.getName(), org.datanucleus.store.rdbms.mapping.column.BinaryColumnMapping.class, JDBCType.BINARY, "RAW", false);
-
- registerColumnMapping(java.io.File.class.getName(), org.datanucleus.store.rdbms.mapping.column.BinaryStreamColumnMapping.class, JDBCType.LONGVARBINARY, "LONGVARBINARY", true);
-
- registerColumnMapping(DatastoreId.class.getName(), org.datanucleus.store.rdbms.mapping.column.NumericColumnMapping.class, JDBCType.NUMERIC, "NUMBER", true);
- registerColumnMapping(DatastoreId.class.getName(), org.datanucleus.store.rdbms.mapping.column.BigIntColumnMapping.class, JDBCType.BIGINT, "BIGINT", false);
- registerColumnMapping(DatastoreId.class.getName(), org.datanucleus.store.rdbms.mapping.column.IntegerColumnMapping.class, JDBCType.INTEGER, "INTEGER", false);
- registerColumnMapping(DatastoreId.class.getName(), org.datanucleus.store.rdbms.mapping.column.CharColumnMapping.class, JDBCType.CHAR, "CHAR", false);
- registerColumnMapping(DatastoreId.class.getName(), org.datanucleus.store.rdbms.mapping.column.VarCharColumnMapping.class, JDBCType.VARCHAR, "VARCHAR", false);
-
- super.loadColumnMappings(mgr, clr);
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/ConnectionFactoryImpl.java 2023-05-12 20:23:47.217323664 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/ConnectionFactoryImpl.java 2023-05-12 20:23:58.865342133 +0200
@@ -46,14 +46,12 @@
import org.datanucleus.store.connection.AbstractManagedConnection;
import org.datanucleus.store.connection.ManagedConnection;
import org.datanucleus.store.rdbms.adapter.DatastoreAdapter;
-import org.datanucleus.store.rdbms.connectionpool.BoneCPConnectionPoolFactory;
import org.datanucleus.store.rdbms.connectionpool.C3P0ConnectionPoolFactory;
import org.datanucleus.store.rdbms.connectionpool.ConnectionPool;
import org.datanucleus.store.rdbms.connectionpool.ConnectionPoolFactory;
import org.datanucleus.store.rdbms.connectionpool.DBCP2BuiltinConnectionPoolFactory;
import org.datanucleus.store.rdbms.connectionpool.DBCP2ConnectionPoolFactory;
import org.datanucleus.store.rdbms.connectionpool.DefaultConnectionPoolFactory;
-import org.datanucleus.store.rdbms.connectionpool.HikariCPConnectionPoolFactory;
import org.datanucleus.store.rdbms.connectionpool.TomcatConnectionPoolFactory;
import org.datanucleus.transaction.Transaction;
import org.datanucleus.transaction.TransactionIsolation;
@@ -214,14 +212,6 @@
{
connPoolFactory = new DBCP2BuiltinConnectionPoolFactory();
}
- else if (poolingType.equalsIgnoreCase("HikariCP"))
- {
- connPoolFactory = new HikariCPConnectionPoolFactory();
- }
- else if (poolingType.equalsIgnoreCase("BoneCP"))
- {
- connPoolFactory = new BoneCPConnectionPoolFactory();
- }
else if (poolingType.equalsIgnoreCase("C3P0"))
{
connPoolFactory = new C3P0ConnectionPoolFactory();
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/connectionpool/BoneCPConnectionPoolFactory.java 2023-05-12 20:23:47.225323676 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/connectionpool/BoneCPConnectionPoolFactory.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,132 +0,0 @@
-/**********************************************************************
-Copyright (c) 2013 Andy Jefferson and others. All rights reserved.
-Licensed 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
-
-http://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.
-
-Contributors:
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.connectionpool;
-
-import java.util.Properties;
-
-import javax.sql.DataSource;
-
-import org.datanucleus.ClassLoaderResolver;
-import org.datanucleus.store.StoreManager;
-import org.datanucleus.store.rdbms.RDBMSPropertyNames;
-import org.datanucleus.util.ClassUtils;
-import org.datanucleus.util.StringUtils;
-
-/**
- * ConnectionFactory for BoneCP pools.
- */
-public class BoneCPConnectionPoolFactory extends AbstractConnectionPoolFactory
-{
- /* (non-Javadoc)
- * @see org.datanucleus.store.rdbms.datasource.ConnectionPoolFactory#createConnectionPool(org.datanucleus.store.StoreManager)
- */
- public ConnectionPool createConnectionPool(StoreManager storeMgr)
- {
- String dbUser = storeMgr.getConnectionUserName();
- if (dbUser == null)
- {
- dbUser = ""; // Some RDBMS (e.g Postgresql) don't like null usernames
- }
- String dbPassword = storeMgr.getConnectionPassword();
- if (dbPassword == null)
- {
- dbPassword = ""; // Some RDBMS (e.g Postgresql) don't like null passwords
- }
- ClassLoaderResolver clr = storeMgr.getNucleusContext().getClassLoaderResolver(null);
-
- // Load the database driver
- String dbDriver = storeMgr.getConnectionDriverName();
- if (!StringUtils.isWhitespace(dbDriver))
- {
- loadDriver(dbDriver, clr);
- }
-
- // Check the existence of the necessary pooling classes
- ClassUtils.assertClassForJarExistsInClasspath(clr, "com.jolbox.bonecp.BoneCPDataSource", "bonecp.jar");
-
- com.jolbox.bonecp.BoneCPConfig config = new com.jolbox.bonecp.BoneCPConfig();
- config.setUsername(dbUser);
- config.setPassword(dbPassword);
- Properties dbProps = getPropertiesForDriver(storeMgr);
- config.setDriverProperties(dbProps);
-
- // Create the actual pool of connections
- com.jolbox.bonecp.BoneCPDataSource ds = new com.jolbox.bonecp.BoneCPDataSource(config);
-
- // Apply any BoneCP properties
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_STATEMENTS))
- {
- int size = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_STATEMENTS);
- if (size >= 0)
- {
- ds.setStatementsCacheSize(size);
- }
- }
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_POOL_SIZE))
- {
- int size = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_POOL_SIZE);
- if (size >= 0)
- {
- ds.setMaxConnectionsPerPartition(size);
- }
- }
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MIN_POOL_SIZE))
- {
- int size = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MIN_POOL_SIZE);
- if (size >= 0)
- {
- ds.setMinConnectionsPerPartition(size);
- }
- }
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_IDLE))
- {
- int value = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_IDLE);
- if (value > 0)
- {
- ds.setIdleMaxAgeInMinutes(value);
- }
- }
-
- if (!StringUtils.isWhitespace(dbDriver))
- {
- ds.setDriverClass(dbDriver);
- }
- ds.setJdbcUrl(storeMgr.getConnectionURL());
- ds.setUsername(dbUser);
- ds.setPassword(dbPassword);
-
- return new BoneCPConnectionPool(ds);
- }
-
- public class BoneCPConnectionPool implements ConnectionPool
- {
- final com.jolbox.bonecp.BoneCPDataSource dataSource;
- public BoneCPConnectionPool(com.jolbox.bonecp.BoneCPDataSource ds)
- {
- dataSource = ds;
- }
- public void close()
- {
- dataSource.close();
- }
- public DataSource getDataSource()
- {
- return dataSource;
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/connectionpool/HikariCPConnectionPoolFactory.java 2023-05-12 20:23:47.225323676 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/connectionpool/HikariCPConnectionPoolFactory.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,192 +0,0 @@
-/**********************************************************************
-Copyright (c) 2014 Andy Jefferson and others. All rights reserved.
-Licensed 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
-
-http://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.
-
-Contributors:
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.connectionpool;
-
-import javax.sql.DataSource;
-
-import org.datanucleus.ClassLoaderResolver;
-import org.datanucleus.store.StoreManager;
-import org.datanucleus.store.rdbms.RDBMSPropertyNames;
-import org.datanucleus.util.ClassUtils;
-import org.datanucleus.util.StringUtils;
-
-import com.zaxxer.hikari.HikariConfig;
-import com.zaxxer.hikari.HikariDataSource;
-
-/**
- * ConnectionFactory for HikariCP pools.
- * See https://github.com/brettwooldridge/HikariCP
- */
-public class HikariCPConnectionPoolFactory extends AbstractConnectionPoolFactory
-{
- /* (non-Javadoc)
- * @see org.datanucleus.store.rdbms.datasource.ConnectionPoolFactory#createConnectionPool(org.datanucleus.store.StoreManager)
- */
- public ConnectionPool createConnectionPool(StoreManager storeMgr)
- {
- // Check the existence of the necessary pooling classes
- ClassLoaderResolver clr = storeMgr.getNucleusContext().getClassLoaderResolver(null);
- ClassUtils.assertClassForJarExistsInClasspath(clr, "com.zaxxer.hikari.HikariConfig", "hikaricp.jar");
-
- HikariConfig config = new HikariConfig();
-
- config.setJdbcUrl(storeMgr.getConnectionURL());
-
- String dbUser = storeMgr.getConnectionUserName();
- if (dbUser == null)
- {
- dbUser = ""; // Some RDBMS (e.g Postgresql) don't like null usernames
- }
- config.setUsername(dbUser);
-
- String dbPassword = storeMgr.getConnectionPassword();
- if (dbPassword == null)
- {
- dbPassword = ""; // Some RDBMS (e.g Postgresql) don't like null passwords
- }
- config.setPassword(dbPassword);
-
- String dbDriver = storeMgr.getConnectionDriverName();
- if (!StringUtils.isWhitespace(dbDriver))
- {
- loadDriver(dbDriver, clr);
- config.setDriverClassName(dbDriver);
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_POOL_SIZE))
- {
- int size = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_POOL_SIZE);
- if (size >= 0)
- {
- config.setMaximumPoolSize(size);
- }
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MIN_IDLE))
- {
- int idle = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MIN_IDLE);
- if (idle >= 0)
- {
- config.setMinimumIdle(idle);
- }
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_IDLE_TIMEOUT))
- {
- long timeout = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_IDLE_TIMEOUT);
- if (timeout >= 0 )
- {
- config.setIdleTimeout(timeout);
- }
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_LEAK_DETECTION_THRESHOLD))
- {
- long threshold = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_LEAK_DETECTION_THRESHOLD);
- if (threshold >= 0)
- {
- config.setLeakDetectionThreshold(threshold);
- }
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_LIFETIME))
- {
- long maxLifeTime = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_MAX_LIFETIME);
- if (maxLifeTime >= 0)
- {
- config.setMaxLifetime(maxLifeTime);
- }
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_AUTO_COMMIT))
- {
- boolean autoCommit = storeMgr.getBooleanProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_AUTO_COMMIT);
- config.setAutoCommit(autoCommit);
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_CONNECTION_WAIT_TIMEOUT))
- {
- long connectionTimeout = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_CONNECTION_WAIT_TIMEOUT);
- if (connectionTimeout >= 0)
- {
- config.setConnectionTimeout(connectionTimeout);
- }
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_NAME))
- {
- String poolName = storeMgr.getStringProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_NAME);
- config.setPoolName(poolName);
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_TRANSACTION_ISOLATION))
- {
- String transactionIsolation = storeMgr.getStringProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_TRANSACTION_ISOLATION);
- config.setTransactionIsolation(transactionIsolation);
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_CATALOG))
- {
- String catalog = storeMgr.getStringProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_CATALOG);
- config.setCatalog(catalog);
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_READ_ONLY))
- {
- boolean readOnly = storeMgr.getBooleanProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_READ_ONLY);
- config.setReadOnly(readOnly);
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_ALLOW_POOL_SUPSENSION))
- {
- boolean allowPoolSuspension = storeMgr.getBooleanProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_ALLOW_POOL_SUPSENSION);
- config.setAllowPoolSuspension(allowPoolSuspension);
- }
-
- if (storeMgr.hasProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_VALIDATION_TIMEOUT))
- {
- long validationTimeout = storeMgr.getIntProperty(RDBMSPropertyNames.PROPERTY_CONNECTION_POOL_VALIDATION_TIMEOUT);
- if (validationTimeout >= 0)
- {
- config.setValidationTimeout(validationTimeout);
- }
- }
-
- // Create the actual pool of connections
- HikariDataSource ds = new HikariDataSource(config);
-
- return new HikariCPConnectionPool(ds);
- }
-
- public class HikariCPConnectionPool implements ConnectionPool
- {
- final HikariDataSource dataSource;
- public HikariCPConnectionPool(HikariDataSource ds)
- {
- dataSource = ds;
- }
- public void close()
- {
- dataSource.close();
- }
- public DataSource getDataSource()
- {
- return dataSource;
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/column/OracleBlobColumnMapping.java 2023-05-12 20:23:47.245323709 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/column/OracleBlobColumnMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,481 +0,0 @@
-/**********************************************************************
-Copyright (c) 2005 Brendan De Beer and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-Contributors:
-2007 Thomas Marti - added handling for String->BLOB mapping
-2009 Andy Jefferson - rewrite SQL to use SQLStatement API methods
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.mapping.column;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.StreamCorruptedException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Blob;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.datanucleus.ClassNameConstants;
-import org.datanucleus.ExecutionContext;
-import org.datanucleus.exceptions.NucleusDataStoreException;
-import org.datanucleus.exceptions.NucleusObjectNotFoundException;
-import org.datanucleus.exceptions.NucleusUserException;
-import org.datanucleus.identity.IdentityUtils;
-import org.datanucleus.metadata.AbstractClassMetaData;
-import org.datanucleus.metadata.AbstractMemberMetaData;
-import org.datanucleus.metadata.IdentityType;
-import org.datanucleus.state.DNStateManager;
-import org.datanucleus.store.connection.ManagedConnection;
-import org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping;
-import org.datanucleus.store.rdbms.query.StatementClassMapping;
-import org.datanucleus.store.rdbms.query.StatementMappingIndex;
-import org.datanucleus.store.rdbms.RDBMSStoreManager;
-import org.datanucleus.store.rdbms.SQLController;
-import org.datanucleus.store.rdbms.adapter.DatastoreAdapter;
-import org.datanucleus.store.rdbms.adapter.OracleAdapter;
-import org.datanucleus.store.rdbms.fieldmanager.ParameterSetter;
-import org.datanucleus.store.rdbms.sql.SQLStatement;
-import org.datanucleus.store.rdbms.sql.SQLStatementHelper;
-import org.datanucleus.store.rdbms.sql.SQLTable;
-import org.datanucleus.store.rdbms.sql.SelectStatement;
-import org.datanucleus.store.rdbms.sql.expression.SQLExpression;
-import org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory;
-import org.datanucleus.store.rdbms.table.Column;
-import org.datanucleus.store.rdbms.table.DatastoreClass;
-import org.datanucleus.store.rdbms.table.Table;
-import org.datanucleus.store.schema.table.SurrogateColumnType;
-import org.datanucleus.store.types.converters.ArrayConversionHelper;
-import org.datanucleus.util.ClassUtils;
-import org.datanucleus.util.Localiser;
-import org.datanucleus.util.NucleusLogger;
-
-import oracle.sql.BLOB;
-
-/**
- * Mapping for an Oracle BLOB column.
- * Extends the standard JDBC handler so that we can insert an empty BLOB, and then update it (Oracle non-standard behaviour).
- */
-public class OracleBlobColumnMapping extends AbstractColumnMapping implements ColumnMappingPostSet
-{
- /**
- * Constructor.
- * @param mapping The Java mapping
- * @param storeMgr Store Manager in use
- * @param col Column
- */
- public OracleBlobColumnMapping(JavaTypeMapping mapping, RDBMSStoreManager storeMgr, Column col)
- {
- super(storeMgr, mapping);
- column = col;
- initialize();
- }
-
- /**
- * Constructor.
- * @param storeMgr Store Manager
- * @param mapping The Java mapping
- */
- protected OracleBlobColumnMapping(RDBMSStoreManager storeMgr, JavaTypeMapping mapping)
- {
- super(storeMgr, mapping);
- }
-
- /**
- * Initialize the mapping.
- */
- private void initialize()
- {
- initTypeInfo();
- }
-
- /**
- * @see org.datanucleus.store.rdbms.mapping.column.AbstractColumnMapping#getInsertionInputParameter()
- */
- public String getInsertionInputParameter()
- {
- return "EMPTY_BLOB()";
- }
-
- /**
- * Accessor for whether this mapping requires values inserting on an INSERT.
- * @return Whether values are to be inserted into this mapping on an INSERT
- */
- public boolean insertValuesOnInsert()
- {
- // We will just insert "EMPTY_BLOB()" above so don't put value in
- return false;
- }
-
- /**
- * Returns the object to be loaded from the Orale BLOB.
- * @param rs the ResultSet from the query
- * @param param the index in the query
- * @return the object loaded as a byte[]
- * @throws NucleusDataStoreException Thrown if an error occurs in datastore communication
- */
- public Object getObject(ResultSet rs, int param)
- {
- Object obj = null;
-
- try
- {
- Blob blob = rs.getBlob(param);
- if (!rs.wasNull())
- {
- byte[] bytes = blob.getBytes(1,(int)blob.length());
- if (bytes.length < 1)
- {
- return null;
- }
- try
- {
- if (getJavaTypeMapping().isSerialised())
- {
- BlobImpl b = new BlobImpl(bytes);
- obj = b.getObject();
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.BOOLEAN_ARRAY))
- {
- obj = ArrayConversionHelper.getBooleanArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.BYTE_ARRAY))
- {
- obj = bytes;
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.CHAR_ARRAY))
- {
- obj = ArrayConversionHelper.getCharArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_STRING))
- {
- obj = new String(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.DOUBLE_ARRAY))
- {
- obj = ArrayConversionHelper.getDoubleArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.FLOAT_ARRAY))
- {
- obj = ArrayConversionHelper.getFloatArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.INT_ARRAY))
- {
- obj = ArrayConversionHelper.getIntArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.LONG_ARRAY))
- {
- obj = ArrayConversionHelper.getLongArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.SHORT_ARRAY))
- {
- obj = ArrayConversionHelper.getShortArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_BOOLEAN_ARRAY))
- {
- obj = ArrayConversionHelper.getBooleanObjectArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_BYTE_ARRAY))
- {
- obj = ArrayConversionHelper.getByteObjectArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_CHARACTER_ARRAY))
- {
- obj = ArrayConversionHelper.getCharObjectArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_DOUBLE_ARRAY))
- {
- obj = ArrayConversionHelper.getDoubleObjectArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_FLOAT_ARRAY))
- {
- obj = ArrayConversionHelper.getFloatObjectArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_INTEGER_ARRAY))
- {
- obj = ArrayConversionHelper.getIntObjectArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_LONG_ARRAY))
- {
- obj = ArrayConversionHelper.getLongObjectArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_SHORT_ARRAY))
- {
- obj = ArrayConversionHelper.getShortObjectArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(BigDecimal[].class.getName()))
- {
- return ArrayConversionHelper.getBigDecimalArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(BigInteger[].class.getName()))
- {
- return ArrayConversionHelper.getBigIntegerArrayFromByteArray(bytes);
- }
- else if (getJavaTypeMapping().getType().equals(java.util.BitSet.class.getName()))
- {
- return ArrayConversionHelper.getBitSetFromBooleanArray(ArrayConversionHelper.getBooleanArrayFromByteArray(bytes));
- }
- else
- {
- obj = new ObjectInputStream(new ByteArrayInputStream(bytes)).readObject();
- }
- }
- catch (StreamCorruptedException e)
- {
- String msg = "StreamCorruptedException: object is corrupted";
- NucleusLogger.DATASTORE.error(msg);
- throw new NucleusUserException(msg, e).setFatal();
- }
- catch (IOException e)
- {
- String msg = "IOException: error when reading object";
- NucleusLogger.DATASTORE.error(msg);
- throw new NucleusUserException(msg, e).setFatal();
- }
- catch (ClassNotFoundException e)
- {
- String msg = "ClassNotFoundException: error when creating object";
- NucleusLogger.DATASTORE.error(msg);
- throw new NucleusUserException(msg, e).setFatal();
- }
- }
- }
- catch (SQLException sqle)
- {
- throw new NucleusDataStoreException(Localiser.msg("055002", "Object", "" + param, column, sqle.getMessage()), sqle);
- }
-
- return obj;
- }
-
- /**
- * @see org.datanucleus.store.rdbms.mapping.column.AbstractColumnMapping#getString(ResultSet, int)
- */
- public String getString(ResultSet resultSet, int exprIndex)
- {
- return (String)getObject(resultSet, exprIndex);
- }
-
- public int getJDBCType()
- {
- return Types.BLOB;
- }
-
- /**
- * @see org.datanucleus.store.rdbms.mapping.column.AbstractColumnMapping#getUpdateInputParameter()
- */
- public String getUpdateInputParameter()
- {
- return "EMPTY_BLOB()";
- }
-
- /**
- * Whether to include this mapping in a fetch statement.
- * @return Whether to include it when fetching the object
- */
- public boolean includeInSQLFetchStatement()
- {
- return true;
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public void setPostProcessing(DNStateManager sm, Object value)
- {
- // Oracle requires that a BLOB is initialised with EMPTY_BLOB() and then you retrieve the column and update its BLOB value. Performs a statement
- // SELECT {blobColumn} FROM TABLE WHERE ID=? FOR UPDATE
- // and then updates the Blob value returned.
- ExecutionContext ec = sm.getExecutionContext();
- byte[] bytes = (byte[])value;
- Table table = column.getTable();
- RDBMSStoreManager storeMgr = table.getStoreManager();
-
- if (table instanceof DatastoreClass)
- {
- // BLOB within a primary table
- DatastoreClass classTable = (DatastoreClass)table;
-
- // Generate "SELECT {blobColumn} FROM TABLE WHERE ID=? FOR UPDATE" statement
- SelectStatement sqlStmt = new SelectStatement(storeMgr, table, null, null);
- sqlStmt.setClassLoaderResolver(ec.getClassLoaderResolver());
- sqlStmt.addExtension(SQLStatement.EXTENSION_LOCK_FOR_UPDATE, true);
- SQLTable blobSqlTbl = SQLStatementHelper.getSQLTableForMappingOfTable(sqlStmt, sqlStmt.getPrimaryTable(), mapping);
- sqlStmt.select(blobSqlTbl, column, null);
- StatementClassMapping mappingDefinition = new StatementClassMapping();
- AbstractClassMetaData cmd = sm.getClassMetaData();
- SQLExpressionFactory exprFactory = storeMgr.getSQLExpressionFactory();
- int inputParamNum = 1;
- if (cmd.getIdentityType() == IdentityType.DATASTORE)
- {
- // Datastore identity value for input
- JavaTypeMapping datastoreIdMapping = classTable.getSurrogateMapping(SurrogateColumnType.DATASTORE_ID, false);
- SQLExpression expr = exprFactory.newExpression(sqlStmt, sqlStmt.getPrimaryTable(), datastoreIdMapping);
- SQLExpression val = exprFactory.newLiteralParameter(sqlStmt, datastoreIdMapping, null, "ID");
- sqlStmt.whereAnd(expr.eq(val), true);
-
- StatementMappingIndex datastoreIdx = mappingDefinition.getMappingForMemberPosition(SurrogateColumnType.DATASTORE_ID.getFieldNumber());
- if (datastoreIdx == null)
- {
- datastoreIdx = new StatementMappingIndex(datastoreIdMapping);
- mappingDefinition.addMappingForMember(SurrogateColumnType.DATASTORE_ID.getFieldNumber(), datastoreIdx);
- }
- datastoreIdx.addParameterOccurrence(new int[] {inputParamNum});
- }
- else if (cmd.getIdentityType() == IdentityType.APPLICATION)
- {
- // Application identity value(s) for input
- int[] pkNums = cmd.getPKMemberPositions();
- for (int i=0;i<pkNums.length;i++)
- {
- AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(pkNums[i]);
- JavaTypeMapping pkMapping = classTable.getMemberMapping(mmd);
- SQLExpression expr = exprFactory.newExpression(sqlStmt, sqlStmt.getPrimaryTable(), pkMapping);
- SQLExpression val = exprFactory.newLiteralParameter(sqlStmt, pkMapping, null, "PK" + i);
- sqlStmt.whereAnd(expr.eq(val), true);
-
- StatementMappingIndex pkIdx = mappingDefinition.getMappingForMemberPosition(pkNums[i]);
- if (pkIdx == null)
- {
- pkIdx = new StatementMappingIndex(pkMapping);
- mappingDefinition.addMappingForMember(pkNums[i], pkIdx);
- }
- int[] inputParams = new int[pkMapping.getNumberOfColumnMappings()];
- for (int j=0;j<pkMapping.getNumberOfColumnMappings();j++)
- {
- inputParams[j] = inputParamNum++;
- }
- pkIdx.addParameterOccurrence(inputParams);
- }
- }
-
- String textStmt = sqlStmt.getSQLText().toSQL();
-
- if (sm.isEmbedded())
- {
- // This mapping is embedded, so navigate back to the real owner since that is the "id" in the table
- DNStateManager embeddedOwner = ec.getOwnerForEmbeddedStateManager(sm);
- if (embeddedOwner != null)
- {
- // TODO Should check if the owner is stored in this table
- sm = embeddedOwner;
- }
- }
-
- try
- {
- ManagedConnection mconn = storeMgr.getConnectionManager().getConnection(ec);
- SQLController sqlControl = storeMgr.getSQLController();
-
- try
- {
- PreparedStatement ps = sqlControl.getStatementForQuery(mconn, textStmt);
- try
- {
- // Provide the primary key field(s) to the JDBC statement
- if (cmd.getIdentityType() == IdentityType.DATASTORE)
- {
- StatementMappingIndex datastoreIdx = mappingDefinition.getMappingForMemberPosition(SurrogateColumnType.DATASTORE_ID.getFieldNumber());
- for (int i=0;i<datastoreIdx.getNumberOfParameterOccurrences();i++)
- {
- classTable.getSurrogateMapping(SurrogateColumnType.DATASTORE_ID, false).setObject(ec, ps,
- datastoreIdx.getParameterPositionsForOccurrence(i), sm.getInternalObjectId());
- }
- }
- else if (cmd.getIdentityType() == IdentityType.APPLICATION)
- {
- sm.provideFields(cmd.getPKMemberPositions(), new ParameterSetter(sm, ps, mappingDefinition));
- }
-
- ResultSet rs = sqlControl.executeStatementQuery(ec, mconn, textStmt, ps);
-
- try
- {
- if (!rs.next())
- {
- throw new NucleusObjectNotFoundException(Localiser.msg("050018", IdentityUtils.getPersistableIdentityForId(sm.getInternalObjectId())));
- }
-
- DatastoreAdapter dba = storeMgr.getDatastoreAdapter();
- int jdbcMajorVersion = dba.getDriverMajorVersion();
- if (dba.getDatastoreDriverName().equalsIgnoreCase(OracleAdapter.OJDBC_DRIVER_NAME) && jdbcMajorVersion < 10)
- {
- oracle.sql.BLOB blob = null;
- if (jdbcMajorVersion <= 8)
- {
- // Oracle JDBC <= v8
- // We are effectively doing the following line but don't want to impose having Oracle <= v10 in the CLASSPATH, just any Oracle driver
- // blob = ((oracle.jdbc.driver.OracleResultSet)rs).getBLOB(1);
- Method getBlobMethod = ClassUtils.getMethodForClass(rs.getClass(), "getBLOB", new Class[] {int.class});
- try
- {
- blob = (BLOB) getBlobMethod.invoke(rs, new Object[] {1});
- }
- catch (Throwable thr)
- {
- throw new NucleusDataStoreException("Error in getting BLOB", thr);
- }
- }
- else
- {
- // Oracle JDBC v9
- blob = (BLOB)rs.getBlob(1);
- }
-
- if (blob != null)
- {
- blob.putBytes(1, bytes); // Deprecated but what can you do
- }
- }
- else
- {
- // Oracle JDBC v10+ supposedly use the JDBC standard class for Blobs
- java.sql.Blob blob = rs.getBlob(1);
- if (blob != null)
- {
- blob.setBytes(1, bytes);
- }
- }
- }
- finally
- {
- rs.close();
- }
- }
- finally
- {
- sqlControl.closeStatement(mconn, ps);
- }
- }
- finally
- {
- mconn.release();
- }
- }
- catch (SQLException e)
- {
- throw new NucleusDataStoreException("Update of BLOB value failed: " + textStmt, e);
- }
- }
- else
- {
- // TODO Support join table
- throw new NucleusDataStoreException("We do not support INSERT/UPDATE BLOB post processing of non-primary table " + table);
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/column/OracleClobColumnMapping.java 2023-05-12 20:23:47.245323709 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/column/OracleClobColumnMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,339 +0,0 @@
-/**********************************************************************
-Copyright (c) 2004 Erik Bengtson and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-Contributors:
-2004 Andy Jefferson - localised messages
-2005 Andrew Hoffman - changed mapping parent class
-2006 Andy Jefferson - add convenience method for updating CLOB
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.mapping.column;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.datanucleus.ExecutionContext;
-import org.datanucleus.exceptions.NucleusDataStoreException;
-import org.datanucleus.exceptions.NucleusObjectNotFoundException;
-import org.datanucleus.identity.IdentityUtils;
-import org.datanucleus.metadata.AbstractClassMetaData;
-import org.datanucleus.metadata.AbstractMemberMetaData;
-import org.datanucleus.metadata.IdentityType;
-import org.datanucleus.state.DNStateManager;
-import org.datanucleus.store.connection.ManagedConnection;
-import org.datanucleus.store.rdbms.exceptions.ColumnDefinitionException;
-import org.datanucleus.store.rdbms.fieldmanager.ParameterSetter;
-import org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping;
-import org.datanucleus.store.rdbms.query.StatementClassMapping;
-import org.datanucleus.store.rdbms.query.StatementMappingIndex;
-import org.datanucleus.store.rdbms.RDBMSStoreManager;
-import org.datanucleus.store.rdbms.SQLController;
-import org.datanucleus.store.rdbms.adapter.DatastoreAdapter;
-import org.datanucleus.store.rdbms.adapter.OracleAdapter;
-import org.datanucleus.store.rdbms.sql.SQLStatement;
-import org.datanucleus.store.rdbms.sql.SQLStatementHelper;
-import org.datanucleus.store.rdbms.sql.SQLTable;
-import org.datanucleus.store.rdbms.sql.SelectStatement;
-import org.datanucleus.store.rdbms.sql.expression.SQLExpression;
-import org.datanucleus.store.rdbms.sql.expression.SQLExpressionFactory;
-import org.datanucleus.store.rdbms.table.Column;
-import org.datanucleus.store.rdbms.table.DatastoreClass;
-import org.datanucleus.store.rdbms.table.Table;
-import org.datanucleus.store.schema.table.SurrogateColumnType;
-import org.datanucleus.util.Localiser;
-
-/**
- * Mapping for an Oracle CLOB column.
- * Extends the standard JDBC handler so that we can insert an empty CLOB, and then update it (Oracle non-standard behaviour).
- */
-public class OracleClobColumnMapping extends ClobColumnMapping implements ColumnMappingPostSet
-{
- public OracleClobColumnMapping(JavaTypeMapping mapping, RDBMSStoreManager storeMgr, Column col)
- {
- super(mapping, storeMgr, col);
- column = col;
- initialize();
- }
-
- private void initialize()
- {
- initTypeInfo();
- if (column != null && !column.isUnlimitedLength())
- {
- throw new ColumnDefinitionException("Invalid length specified for CLOB column " + column + ", must be 'unlimited'");
- }
- }
-
- public String getInsertionInputParameter()
- {
- return "EMPTY_CLOB()";
- }
-
- public boolean includeInFetchStatement()
- {
- return true;
- }
-
- public String getUpdateInputParameter()
- {
- return "EMPTY_CLOB()";
- }
-
- /**
- * Accessor for whether this mapping requires values inserting on an INSERT.
- * @return Whether values are to be inserted into this mapping on an INSERT
- */
- public boolean insertValuesOnInsert()
- {
- // We will just insert "EMPTY_CLOB()" above so dont put value in
- return false;
- }
-
- public String getString(ResultSet rs, int param)
- {
- String value = null;
-
- try
- {
- char[] cbuf = null;
- java.sql.Clob clob = rs.getClob(param);
-
- if (clob != null)
- {
- // Note: Using clob.stringValue() results in StoreManagerTest
- // exception: "java.sql.SQLException: Conversion to String failed"
-
- StringBuilder sbuf = new StringBuilder();
- Reader reader = clob.getCharacterStream();
- try
- {
- final int BUFF_SIZE = 4096;
- cbuf = new char[BUFF_SIZE];
- int charsRead = reader.read(cbuf);
-
- while (-1 != charsRead)
- {
- sbuf.append(cbuf, 0, charsRead);
-
- java.util.Arrays.fill(cbuf, (char)0);
- charsRead = reader.read(cbuf);
- }
- }
- catch (IOException e)
- {
- throw new NucleusDataStoreException("Error reading Oracle CLOB object: param = " + param, e);
- }
- finally
- {
- try
- {
- reader.close();
- }
- catch (IOException e)
- {
- throw new NucleusDataStoreException("Error reading Oracle CLOB object: param = " + param, e);
- }
- }
-
- value = sbuf.toString();
-
- if (value.length() == 0)
- {
- value = null;
- }
- else if (value.equals(getDatastoreAdapter().getSurrogateForEmptyStrings()))
- {
- value = "";
- }
- }
- }
- catch (SQLException e)
- {
- throw new NucleusDataStoreException(Localiser.msg("055001","String", "" + param), e);
- }
-
- return value;
- }
-
- public Object getObject(ResultSet rs, int param)
- {
- return getString(rs, param);
- }
-
- @SuppressWarnings("deprecation")
- @Override
- public void setPostProcessing(DNStateManager sm, Object value)
- {
- String stringValue = (String)value;
- ExecutionContext ec = sm.getExecutionContext();
- Table table = column.getTable();
- RDBMSStoreManager storeMgr = table.getStoreManager();
-
- if (table instanceof DatastoreClass)
- {
- // CLOB within a primary table
- DatastoreClass classTable = (DatastoreClass)table;
-
- // Generate "SELECT {clobColumn} FROM TABLE WHERE ID=? FOR UPDATE" statement
- SelectStatement sqlStmt = new SelectStatement(storeMgr, table, null, null);
- sqlStmt.setClassLoaderResolver(ec.getClassLoaderResolver());
- sqlStmt.addExtension(SQLStatement.EXTENSION_LOCK_FOR_UPDATE, true);
- SQLTable blobSqlTbl = SQLStatementHelper.getSQLTableForMappingOfTable(sqlStmt, sqlStmt.getPrimaryTable(), mapping);
- sqlStmt.select(blobSqlTbl, column, null);
- StatementClassMapping mappingDefinition = new StatementClassMapping();
- AbstractClassMetaData cmd = sm.getClassMetaData();
- SQLExpressionFactory exprFactory = storeMgr.getSQLExpressionFactory();
-
- int inputParamNum = 1;
- if (cmd.getIdentityType() == IdentityType.DATASTORE)
- {
- // Datastore identity value for input
- JavaTypeMapping datastoreIdMapping = classTable.getSurrogateMapping(SurrogateColumnType.DATASTORE_ID, false);
- SQLExpression expr = exprFactory.newExpression(sqlStmt, sqlStmt.getPrimaryTable(), datastoreIdMapping);
- SQLExpression val = exprFactory.newLiteralParameter(sqlStmt, datastoreIdMapping, null, "ID");
- sqlStmt.whereAnd(expr.eq(val), true);
-
- StatementMappingIndex datastoreIdx = mappingDefinition.getMappingForMemberPosition(SurrogateColumnType.DATASTORE_ID.getFieldNumber());
- if (datastoreIdx == null)
- {
- datastoreIdx = new StatementMappingIndex(datastoreIdMapping);
- mappingDefinition.addMappingForMember(SurrogateColumnType.DATASTORE_ID.getFieldNumber(), datastoreIdx);
- }
- datastoreIdx.addParameterOccurrence(new int[] {inputParamNum});
- }
- else if (cmd.getIdentityType() == IdentityType.APPLICATION)
- {
- // Application identity value(s) for input
- int[] pkNums = cmd.getPKMemberPositions();
- for (int i=0;i<pkNums.length;i++)
- {
- AbstractMemberMetaData mmd = cmd.getMetaDataForManagedMemberAtAbsolutePosition(pkNums[i]);
- JavaTypeMapping pkMapping = classTable.getMemberMapping(mmd);
- SQLExpression expr = exprFactory.newExpression(sqlStmt, sqlStmt.getPrimaryTable(), pkMapping);
- SQLExpression val = exprFactory.newLiteralParameter(sqlStmt, pkMapping, null, "PK" + i);
- sqlStmt.whereAnd(expr.eq(val), true);
-
- StatementMappingIndex pkIdx = mappingDefinition.getMappingForMemberPosition(pkNums[i]);
- if (pkIdx == null)
- {
- pkIdx = new StatementMappingIndex(pkMapping);
- mappingDefinition.addMappingForMember(pkNums[i], pkIdx);
- }
- int[] inputParams = new int[pkMapping.getNumberOfColumnMappings()];
- for (int j=0;j<pkMapping.getNumberOfColumnMappings();j++)
- {
- inputParams[j] = inputParamNum++;
- }
- pkIdx.addParameterOccurrence(inputParams);
- }
- }
-
- String textStmt = sqlStmt.getSQLText().toSQL();
-
- if (sm.isEmbedded())
- {
- // This mapping is embedded, so navigate back to the real owner since that is the "id" in the table
- DNStateManager embeddedOwner = ec.getOwnerForEmbeddedStateManager(sm);
- if (embeddedOwner != null)
- {
- // TODO Should check if the owner is stored in this table
- sm = embeddedOwner;
- }
- }
-
- try
- {
- ManagedConnection mconn = storeMgr.getConnectionManager().getConnection(ec);
- SQLController sqlControl = storeMgr.getSQLController();
-
- try
- {
- PreparedStatement ps = sqlControl.getStatementForQuery(mconn, textStmt);
-
- try
- {
- // Provide the primary key field(s) to the JDBC statement
- if (cmd.getIdentityType() == IdentityType.DATASTORE)
- {
- StatementMappingIndex datastoreIdx = mappingDefinition.getMappingForMemberPosition(SurrogateColumnType.DATASTORE_ID.getFieldNumber());
- for (int i=0;i<datastoreIdx.getNumberOfParameterOccurrences();i++)
- {
- classTable.getSurrogateMapping(SurrogateColumnType.DATASTORE_ID, false).setObject(ec, ps,
- datastoreIdx.getParameterPositionsForOccurrence(i), sm.getInternalObjectId());
- }
- }
- else if (cmd.getIdentityType() == IdentityType.APPLICATION)
- {
- sm.provideFields(cmd.getPKMemberPositions(), new ParameterSetter(sm, ps, mappingDefinition));
- }
-
- ResultSet rs = sqlControl.executeStatementQuery(ec, mconn, textStmt, ps);
- try
- {
- if (!rs.next())
- {
- throw new NucleusObjectNotFoundException(Localiser.msg("050018", IdentityUtils.getPersistableIdentityForId(sm.getInternalObjectId())));
- }
-
- DatastoreAdapter dba = storeMgr.getDatastoreAdapter();
- int jdbcMajorVersion = dba.getDriverMajorVersion();
- if (dba.getDatastoreDriverName().equalsIgnoreCase(OracleAdapter.OJDBC_DRIVER_NAME) && jdbcMajorVersion < 10)
- {
- // Oracle JDBC drivers version 9 and below use some sh*tty Oracle-specific CLOB type
- oracle.sql.CLOB clob = (oracle.sql.CLOB)rs.getClob(1);
- if (clob != null)
- {
- clob.putString(1, stringValue); // Deprecated but what can you do
- }
- }
- else
- {
- // Oracle JDBC drivers 10 and above supposedly use the JDBC standard class for Clobs
- java.sql.Clob clob = rs.getClob(1);
- if (clob != null)
- {
- clob.setString(1, stringValue);
- }
- }
- }
- finally
- {
- rs.close();
- }
- }
- finally
- {
- sqlControl.closeStatement(mconn, ps);
- }
- }
- finally
- {
- mconn.release();
- }
- }
- catch (SQLException e)
- {
- throw new NucleusDataStoreException("Update of CLOB value failed: " + textStmt, e);
- }
- }
- else
- {
- // TODO Support join table
- throw new NucleusDataStoreException("We do not support INSERT/UPDATE CLOB post processing of non-primary table " + table);
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/column/OracleXMLTypeColumnMapping.java 2023-05-12 20:23:47.245323709 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/column/OracleXMLTypeColumnMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,123 +0,0 @@
-/**********************************************************************
-Copyright (c) 2005 Erik Bengtson and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-Contributors:
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.mapping.column;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import org.datanucleus.exceptions.NucleusDataStoreException;
-import org.datanucleus.store.rdbms.RDBMSStoreManager;
-import org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping;
-import org.datanucleus.store.rdbms.adapter.DatastoreAdapter;
-import org.datanucleus.store.rdbms.adapter.OracleTypeInfo;
-import org.datanucleus.store.rdbms.table.Column;
-import org.datanucleus.util.Localiser;
-
-/**
- * Mapping for an Oracle XMLType column.
- **/
-public class OracleXMLTypeColumnMapping extends CharColumnMapping
-{
- /**
- * Constructor.
- * @param mapping Java type mapping
- * @param storeMgr Store Manager
- * @param col Column
- */
- public OracleXMLTypeColumnMapping(JavaTypeMapping mapping, RDBMSStoreManager storeMgr, Column col)
- {
- super(mapping, storeMgr, col);
- }
-
- protected void initialize()
- {
- initTypeInfo();
- }
-
- public int getJDBCType()
- {
- return OracleTypeInfo.TYPES_SYS_XMLTYPE;
- }
-
- /**
- * Method to extract a String from the ResultSet at the specified position
- * @param rs The Result Set
- * @param param The parameter position
- * @return the String
- */
- public String getString(ResultSet rs, int param)
- {
- String value = null;
-
- try
- {
- oracle.sql.OPAQUE o = (oracle.sql.OPAQUE)rs.getObject(param);
- if (o != null)
- {
- value = oracle.xdb.XMLType.createXML(o).getStringVal();
- }
-
- if (getDatastoreAdapter().supportsOption(DatastoreAdapter.NULL_EQUALS_EMPTY_STRING))
- {
- if (value != null && value.equals(getDatastoreAdapter().getSurrogateForEmptyStrings()))
- {
- value = "";
- }
- }
- }
- catch (SQLException e)
- {
- throw new NucleusDataStoreException(Localiser.msg("055001","String","" + param, column, e.getMessage()), e);
- }
-
- return value;
- }
-
- /**
- * Method to set a String at the specified position in the JDBC PreparedStatement.
- * @param ps The PreparedStatement
- * @param param Parameter position
- * @param value The value to set
- */
- public void setString(PreparedStatement ps, int param, String value)
- {
- try
- {
- if (value == null)
- {
- if (useDefaultWhenNull())
- {
- ps.setString(param, column.getDefaultValue().toString().trim());
- }
- else
- {
- ps.setNull(param, getJDBCType(), "SYS.XMLTYPE");
- }
- }
- else
- {
- ps.setString(param, value);
- }
- }
- catch (SQLException e)
- {
- throw new NucleusDataStoreException(Localiser.msg("055001","String","" + value, column, e.getMessage()), e);
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleArrayMapping.java 2023-05-12 20:23:47.249323715 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleArrayMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,245 +0,0 @@
-/**********************************************************************
- Copyright (c) 2005 Andy Jefferson and others. All rights reserved.
- Licensed 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
-
- http://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.
-
-
- Contributors:
- ...
- **********************************************************************/
-package org.datanucleus.store.rdbms.mapping.java;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.SQLException;
-
-import org.datanucleus.ExecutionContext;
-import org.datanucleus.PersistableObjectType;
-import org.datanucleus.exceptions.NucleusDataStoreException;
-import org.datanucleus.state.DNStateManager;
-import org.datanucleus.store.rdbms.mapping.column.BlobImpl;
-import org.datanucleus.store.rdbms.mapping.column.ColumnMappingPostSet;
-import org.datanucleus.store.types.converters.ArrayConversionHelper;
-import org.datanucleus.util.Localiser;
-
-/**
- * Oracle variant of the ArrayMapping for cases where we are serialising the field into a single (BLOB/CLOB) column
- */
-public class OracleArrayMapping extends ArrayMapping
-{
- public void performSetPostProcessing(DNStateManager sm)
- {
- if (containerIsStoredInSingleColumn())
- {
- if (columnMappings[0] instanceof ColumnMappingPostSet)
- {
- // Create the value to put in the BLOB
- Object value = sm.provideField(mmd.getAbsoluteFieldNumber());
- if (value == null)
- {
- return;
- }
- byte[] bytes = new byte[0];
- try
- {
- if (mmd.isSerialized())
- {
- // Serialised field so just perform basic Java serialisation for retrieval
- if (!(value instanceof Serializable))
- {
- throw new NucleusDataStoreException(Localiser.msg("055005", value.getClass().getName()));
- }
- BlobImpl b = new BlobImpl(value);
- bytes = b.getBytes(0, (int) b.length());
- }
- else if (value instanceof boolean[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromBooleanArray((boolean[]) value);
- }
- else if (value instanceof char[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromCharArray((char[]) value);
- }
- else if (value instanceof double[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromDoubleArray((double[]) value);
- }
- else if (value instanceof float[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromFloatArray((float[]) value);
- }
- else if (value instanceof int[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromIntArray((int[]) value);
- }
- else if (value instanceof long[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromLongArray((long[]) value);
- }
- else if (value instanceof short[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromShortArray((short[]) value);
- }
- else if (value instanceof Boolean[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromBooleanObjectArray((Boolean[]) value);
- }
- else if (value instanceof Byte[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromByteObjectArray((Byte[]) value);
- }
- else if (value instanceof Character[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromCharObjectArray((Character[]) value);
- }
- else if (value instanceof Double[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromDoubleObjectArray((Double[]) value);
- }
- else if (value instanceof Float[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromFloatObjectArray((Float[]) value);
- }
- else if (value instanceof Integer[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromIntObjectArray((Integer[]) value);
- }
- else if (value instanceof Long[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromLongObjectArray((Long[]) value);
- }
- else if (value instanceof Short[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromShortObjectArray((Short[]) value);
- }
- else if (value instanceof BigDecimal[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromBigDecimalArray((BigDecimal[]) value);
- }
- else if (value instanceof BigInteger[])
- {
- bytes = ArrayConversionHelper.getByteArrayFromBigIntegerArray((BigInteger[]) value);
- }
- else if (value instanceof byte[])
- {
- bytes = (byte[]) value;
- }
- else if (value instanceof java.util.BitSet)
- {
- bytes = ArrayConversionHelper.getByteArrayFromBooleanArray(ArrayConversionHelper.getBooleanArrayFromBitSet((java.util.BitSet) value));
- }
- else
- {
- // Fall back to just perform Java serialisation for storage
- if (!(value instanceof Serializable))
- {
- throw new NucleusDataStoreException(Localiser.msg("055005", value.getClass().getName()));
- }
- BlobImpl b = new BlobImpl(value);
- bytes = b.getBytes(0, (int) b.length());
- }
- }
- catch (SQLException e)
- {
- throw new NucleusDataStoreException(Localiser.msg("055001", "Object", "" + value, mmd, e.getMessage()), e);
- }
- catch (IOException e1)
- {
- // Do nothing
- }
-
- // Update the BLOB
- ((ColumnMappingPostSet)columnMappings[0]).setPostProcessing(sm, bytes);
- }
- }
- }
-
- /**
- * Method to be called after the insert of the owner class element.
- * @param ownerSM StateManager of the owner
- */
- public void postInsert(DNStateManager ownerSM)
- {
- if (containerIsStoredInSingleColumn())
- {
- Object value = ownerSM.provideField(mmd.getAbsoluteFieldNumber());
- if (value == null)
- {
- return;
- }
- ExecutionContext ec = ownerSM.getExecutionContext();
-
- if (mmd.getArray().elementIsPersistent())
- {
- // Make sure all persistable elements have StateManagers
- Object[] arrElements = (Object[])value;
- for (Object elem : arrElements)
- {
- if (elem != null)
- {
- DNStateManager elemSM = ec.findStateManager(elem);
- if (elemSM == null || ec.getApiAdapter().getExecutionContext(elem) == null)
- {
- elemSM = ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, elem, false,
- ownerSM, mmd.getAbsoluteFieldNumber(), PersistableObjectType.EMBEDDED_ARRAY_ELEMENT_PC);
- }
- }
- }
- }
- }
- else
- {
- super.postInsert(ownerSM);
- }
- }
-
- /**
- * Method to be called after any update of the owner class element.
- * @param ownerSM StateManager of the owner
- */
- public void postUpdate(DNStateManager ownerSM)
- {
- if (containerIsStoredInSingleColumn())
- {
- Object value = ownerSM.provideField(mmd.getAbsoluteFieldNumber());
- if (value == null)
- {
- return;
- }
- ExecutionContext ec = ownerSM.getExecutionContext();
-
- if (mmd.getArray().elementIsPersistent())
- {
- // Make sure all persistable elements have StateManagers
- Object[] arrElements = (Object[])value;
- for (Object elem : arrElements)
- {
- if (elem != null)
- {
- DNStateManager elemSM = ec.findStateManager(elem);
- if (elemSM == null || ec.getApiAdapter().getExecutionContext(elem) == null)
- {
- elemSM = ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, elem, false,
- ownerSM, mmd.getAbsoluteFieldNumber(), PersistableObjectType.EMBEDDED_ARRAY_ELEMENT_PC);
- }
- }
- }
- }
- }
- else
- {
- super.postUpdate(ownerSM);
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleBitSetMapping.java 2023-05-12 20:23:47.249323715 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleBitSetMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,93 +0,0 @@
-/**********************************************************************
-Copyright (c) 2006 Erik Bengtson and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-
-Contributors:
-2006 Andy Jefferson - commonised approach to BLOB writing as other Oracle mappings
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.mapping.java;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.sql.SQLException;
-
-import org.datanucleus.exceptions.NucleusDataStoreException;
-import org.datanucleus.state.DNStateManager;
-import org.datanucleus.store.rdbms.mapping.column.BlobImpl;
-import org.datanucleus.store.rdbms.mapping.column.ColumnMappingPostSet;
-import org.datanucleus.store.types.converters.ArrayConversionHelper;
-import org.datanucleus.util.Localiser;
-
-/**
- * Mapping for a BitSet type for Oracle.
- */
-public class OracleBitSetMapping extends BitSetMapping
-{
- /**
- * Retrieve the empty BLOB created by the insert statement and write out the current BLOB field value to the Oracle BLOB object
- * @param sm the current StateManager
- */
- public void performSetPostProcessing(DNStateManager sm)
- {
- Object value = sm.provideField(mmd.getAbsoluteFieldNumber());
- if (value == null)
- {
- return;
- }
-
- // Generate the contents for the BLOB
- byte[] bytes = new byte[0];
- try
- {
- if (mmd.isSerialized())
- {
- // Serialised field so just perform basic Java serialisation for retrieval
- if (!(value instanceof Serializable))
- {
- throw new NucleusDataStoreException(Localiser.msg("055005", value.getClass().getName()));
- }
- BlobImpl b = new BlobImpl(value);
- bytes = b.getBytes(0, (int) b.length());
- }
- else if (value instanceof java.util.BitSet)
- {
- bytes = ArrayConversionHelper.getByteArrayFromBooleanArray(ArrayConversionHelper.getBooleanArrayFromBitSet((java.util.BitSet) value));
- }
- else
- {
- // Fall back to just perform Java serialisation for storage
- if (!(value instanceof Serializable))
- {
- throw new NucleusDataStoreException(Localiser.msg("055005", value.getClass().getName()));
- }
- BlobImpl b = new BlobImpl(value);
- bytes = b.getBytes(0, (int) b.length());
- }
- }
- catch (SQLException e)
- {
- throw new NucleusDataStoreException(Localiser.msg("055001", "Object", "" + value, mmd, e.getMessage()), e);
- }
- catch (IOException e1)
- {
- // Do nothing
- }
-
- if (columnMappings[0] instanceof ColumnMappingPostSet)
- {
- ((ColumnMappingPostSet)columnMappings[0]).setPostProcessing(sm, bytes);
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleCollectionMapping.java 2023-05-12 20:23:47.249323715 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleCollectionMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,135 +0,0 @@
-/**********************************************************************
-Copyright (c) 2006 Andy Jefferson and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-Contributors:
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.mapping.java;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.util.Collection;
-
-import org.datanucleus.ExecutionContext;
-import org.datanucleus.PersistableObjectType;
-import org.datanucleus.state.DNStateManager;
-import org.datanucleus.store.rdbms.mapping.column.ColumnMappingPostSet;
-
-/**
- * Oracle variant of the CollectionMapping for cases where we are serialising the field into a single (BLOB/CLOB) column.
- */
-public class OracleCollectionMapping extends CollectionMapping
-{
- @Override
- public void performSetPostProcessing(DNStateManager sm)
- {
- if (containerIsStoredInSingleColumn())
- {
- if (columnMappings[0] instanceof ColumnMappingPostSet)
- {
- // Create the value to put in the BLOB
- Collection value = (Collection) sm.provideField(mmd.getAbsoluteFieldNumber());
- byte[] bytes = new byte[0];
- if (value != null)
- {
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(value);
- bytes = baos.toByteArray();
- }
- catch (IOException e1)
- {
- // Do Nothing
- }
- }
-
- // Update the BLOB
- ((ColumnMappingPostSet)columnMappings[0]).setPostProcessing(sm, bytes);
- }
- }
- }
-
- @Override
- public void postInsert(DNStateManager ownerSM)
- {
- if (containerIsStoredInSingleColumn())
- {
- ExecutionContext ec = ownerSM.getExecutionContext();
- Collection value = (Collection) ownerSM.provideField(mmd.getAbsoluteFieldNumber());
-
- if (value != null)
- {
- if (mmd.getCollection().elementIsPersistent())
- {
- // Make sure all persistable elements have StateManagers
- Object[] collElements = value.toArray();
- for (Object elem : collElements)
- {
- if (elem != null)
- {
- DNStateManager elemSM = ec.findStateManager(elem);
- if (elemSM == null || ec.getApiAdapter().getExecutionContext(elem) == null)
- {
- elemSM = ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, elem, false,
- ownerSM, mmd.getAbsoluteFieldNumber(), PersistableObjectType.EMBEDDED_COLLECTION_ELEMENT_PC);
- }
- }
- }
- }
- }
- }
- else
- {
- super.postInsert(ownerSM);
- }
- }
-
- @Override
- public void postUpdate(DNStateManager ownerSM)
- {
- if (containerIsStoredInSingleColumn())
- {
- ExecutionContext ec = ownerSM.getExecutionContext();
- Collection value = (Collection) ownerSM.provideField(mmd.getAbsoluteFieldNumber());
-
- if (value != null)
- {
- if (mmd.getCollection().elementIsPersistent())
- {
- // Make sure all persistable elements have StateManagers
- Object[] collElements = value.toArray();
- for (Object elem : collElements)
- {
- if (elem != null)
- {
- DNStateManager elemSM = ec.findStateManager(elem);
- if (elemSM == null || ec.getApiAdapter().getExecutionContext(elem) == null)
- {
- elemSM = ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, elem, false,
- ownerSM, mmd.getAbsoluteFieldNumber(), PersistableObjectType.EMBEDDED_COLLECTION_ELEMENT_PC);
- }
- }
- }
- }
- }
- }
- else
- {
- super.postUpdate(ownerSM);
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleMapMapping.java 2023-05-12 20:23:47.249323715 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleMapMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,160 +0,0 @@
-/**********************************************************************
-Copyright (c) 2006 Andy Jefferson and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-Contributors:
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.mapping.java;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.datanucleus.ExecutionContext;
-import org.datanucleus.PersistableObjectType;
-import org.datanucleus.state.DNStateManager;
-import org.datanucleus.store.rdbms.mapping.column.ColumnMappingPostSet;
-
-/**
- * Oracle variant of the MapMapping for cases where we are serialising the field into a single (BLOB/CLOB) column.
- */
-public class OracleMapMapping extends MapMapping
-{
- @Override
- public void performSetPostProcessing(DNStateManager sm)
- {
- if (containerIsStoredInSingleColumn())
- {
- if (columnMappings[0] instanceof ColumnMappingPostSet)
- {
- // Create the value to put in the BLOB
- java.util.Map value = (java.util.Map)sm.provideField(mmd.getAbsoluteFieldNumber());
- byte[] bytes = new byte[0];
- if (value != null)
- {
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(value);
- bytes = baos.toByteArray();
- }
- catch (IOException e1)
- {
- // Do Nothing
- }
- }
-
- // Update the BLOB
- ((ColumnMappingPostSet)columnMappings[0]).setPostProcessing(sm, bytes);
- }
- }
- }
-
- @Override
- public void postInsert(DNStateManager ownerSM)
- {
- if (containerIsStoredInSingleColumn())
- {
- ExecutionContext ec = ownerSM.getExecutionContext();
- java.util.Map value = (java.util.Map) ownerSM.provideField(mmd.getAbsoluteFieldNumber());
-
- // Do nothing when serialised since we are handled in the main request
- if (value != null)
- {
- if (mmd.getMap().keyIsPersistent() || mmd.getMap().valueIsPersistent())
- {
- // Make sure all persistable keys/values have StateManagers
- Set entries = value.entrySet();
- Iterator iter = entries.iterator();
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
- if (mmd.getMap().keyIsPersistent() && entry.getKey() != null)
- {
- Object key = entry.getKey();
- if (ec.findStateManager(key) == null || ec.getApiAdapter().getExecutionContext(key) == null)
- {
- ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, key, false,
- ownerSM, mmd.getAbsoluteFieldNumber(), PersistableObjectType.EMBEDDED_MAP_KEY_PC);
- }
- }
- if (mmd.getMap().valueIsPersistent() && entry.getValue() != null)
- {
- Object val = entry.getValue();
- if (ec.findStateManager(val) == null || ec.getApiAdapter().getExecutionContext(val) == null)
- {
- ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, val, false,
- ownerSM, mmd.getAbsoluteFieldNumber(), PersistableObjectType.EMBEDDED_MAP_VALUE_PC);
- }
- }
- }
- }
- }
- }
- else
- {
- super.postInsert(ownerSM);
- }
- }
-
- @Override
- public void postUpdate(DNStateManager ownerSM)
- {
- if (containerIsStoredInSingleColumn())
- {
- ExecutionContext ec = ownerSM.getExecutionContext();
- java.util.Map value = (java.util.Map) ownerSM.provideField(mmd.getAbsoluteFieldNumber());
-
- if (value != null)
- {
- if (mmd.getMap().keyIsPersistent() || mmd.getMap().valueIsPersistent())
- {
- // Make sure all persistable keys/values have StateManagers
- Set entries = value.entrySet();
- Iterator iter = entries.iterator();
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
- if (mmd.getMap().keyIsPersistent() && entry.getKey() != null)
- {
- Object key = entry.getKey();
- if (ec.findStateManager(key) == null || ec.getApiAdapter().getExecutionContext(key) == null)
- {
- ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, key, false,
- ownerSM, mmd.getAbsoluteFieldNumber(), PersistableObjectType.EMBEDDED_MAP_KEY_PC);
- }
- }
- if (mmd.getMap().valueIsPersistent() && entry.getValue() != null)
- {
- Object val = entry.getValue();
- if (ec.findStateManager(val) == null || ec.getApiAdapter().getExecutionContext(val) == null)
- {
- ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, val, false,
- ownerSM, mmd.getAbsoluteFieldNumber(), PersistableObjectType.EMBEDDED_MAP_VALUE_PC);
- }
- }
- }
- }
- }
- }
- else
- {
- super.postUpdate(ownerSM);
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleSerialisedObjectMapping.java 2023-05-12 20:23:47.249323715 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleSerialisedObjectMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,63 +0,0 @@
-/**********************************************************************
-Copyright (c) 2005 Brendan De Beer and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-
-Contributors:
- ...
- **********************************************************************/
-package org.datanucleus.store.rdbms.mapping.java;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
-import org.datanucleus.state.DNStateManager;
-import org.datanucleus.store.rdbms.mapping.column.ColumnMappingPostSet;
-
-/**
- * Mapping for Object and Serializable types with Oracle.
- */
-public class OracleSerialisedObjectMapping extends SerialisedMapping
-{
- /**
- * Retrieve the empty BLOB created by the insert statement and write out the current BLOB field value to the Oracle BLOB object
- * @param sm the current StateManager
- */
- public void performSetPostProcessing(DNStateManager sm)
- {
- // Generate the contents for the BLOB
- byte[] bytes = new byte[0];
- Object value = sm.provideField(mmd.getAbsoluteFieldNumber());
- if (value != null)
- {
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(value);
- bytes = baos.toByteArray();
- }
- catch (IOException e1)
- {
- // Do Nothing
- }
- }
-
- if (columnMappings[0] instanceof ColumnMappingPostSet)
- {
- // Update the BLOB
- ((ColumnMappingPostSet)columnMappings[0]).setPostProcessing(sm, bytes);
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleSerialisedPCMapping.java 2023-05-12 20:23:47.249323715 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleSerialisedPCMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,87 +0,0 @@
-/**********************************************************************
-Copyright (c) 2006 Andy Jefferson and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-
-Contributors:
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.mapping.java;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
-import org.datanucleus.ExecutionContext;
-import org.datanucleus.PersistableObjectType;
-import org.datanucleus.state.DNStateManager;
-import org.datanucleus.store.rdbms.mapping.column.ColumnMappingPostSet;
-
-/**
- * Mapping for a serialised persistable object for Oracle.
- */
-public class OracleSerialisedPCMapping extends SerialisedPCMapping
-{
- /**
- * Retrieve the empty BLOB created by the insert statement and write out the current BLOB field value to the Oracle BLOB object
- * @param ownerSM the current StateManager
- */
- public void performSetPostProcessing(DNStateManager ownerSM)
- {
- Object value = ownerSM.provideField(mmd.getAbsoluteFieldNumber());
- DNStateManager sm = null;
- if (value != null)
- {
- ExecutionContext ec = ownerSM.getExecutionContext();
- sm = ec.findStateManager(value);
- if (sm == null || sm.getExecutionContext().getApiAdapter().getExecutionContext(value) == null)
- {
- // Assign a StateManager to the serialised object since none present
- sm = ec.getNucleusContext().getStateManagerFactory().newForEmbedded(ec, value, false, ownerSM, mmd.getAbsoluteFieldNumber(), PersistableObjectType.EMBEDDED_PC);
- }
- }
-
- if (sm != null)
- {
- sm.setStoringPC();
- }
-
- // Generate the contents for the BLOB
- byte[] bytes = new byte[0];
- if (value != null)
- {
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(value);
- bytes = baos.toByteArray();
- }
- catch (IOException e1)
- {
- // Do Nothing
- }
- }
-
- // Update the BLOB
- if (columnMappings[0] instanceof ColumnMappingPostSet)
- {
- ((ColumnMappingPostSet)columnMappings[0]).setPostProcessing(ownerSM, bytes);
- }
-
- if (sm != null)
- {
- sm.unsetStoringPC();
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleStringLobMapping.java 2023-05-12 20:23:47.249323715 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/java/OracleStringLobMapping.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,76 +0,0 @@
-/**********************************************************************
-Copyright (c) 2002 Kelly Grizzle (TJDO) and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-
-Contributors:
-2002 Mike Martin (TJDO)
-2003 Andy Jefferson - coding standards
-2004 Erik Bengtson - changed to use EMPTY_CLOB approach
-2006 Andy Jefferson - use commonised CLOB method
-2007 Thomas Marti - added BLOB handling
- ...
-**********************************************************************/
-package org.datanucleus.store.rdbms.mapping.java;
-
-import org.datanucleus.state.DNStateManager;
-import org.datanucleus.store.rdbms.RDBMSPropertyNames;
-import org.datanucleus.store.rdbms.mapping.column.ColumnMappingPostSet;
-import org.datanucleus.store.rdbms.mapping.column.OracleBlobColumnMapping;
-import org.datanucleus.store.rdbms.mapping.column.OracleClobColumnMapping;
-
-/**
- * Mapping for a String type for Oracle when stored in a BLOB or CLOB column.
- */
-public class OracleStringLobMapping extends StringMapping
-{
- /**
- * Retrieve the empty BLOB/CLOB locator created by the insert statement and write out the current BLOB/CLOB field value to the Oracle BLOB/CLOB object
- * @param sm StateManager owner of this field
- */
- @Override
- public void performSetPostProcessing(DNStateManager sm)
- {
- // Generate the contents for the BLOB/CLOB
- String value = (String)sm.provideField(mmd.getAbsoluteFieldNumber());
- sm.isLoaded(mmd.getAbsoluteFieldNumber());
- if (value == null)
- {
- value = "";
- }
- else if (value.length() == 0)
- {
- if (storeMgr.getBooleanProperty(RDBMSPropertyNames.PROPERTY_RDBMS_PERSIST_EMPTY_STRING_AS_NULL))
- {
- value = "";
- }
- else
- {
- value = storeMgr.getDatastoreAdapter().getSurrogateForEmptyStrings();
- }
- }
-
- // Update BLOB/CLOB value
- if (columnMappings[0] instanceof ColumnMappingPostSet)
- {
- if (columnMappings[0] instanceof OracleBlobColumnMapping)
- {
- ((ColumnMappingPostSet)columnMappings[0]).setPostProcessing(sm, value.getBytes());
- }
- else if (columnMappings[0] instanceof OracleClobColumnMapping)
- {
- ((ColumnMappingPostSet)columnMappings[0]).setPostProcessing(sm, value);
- }
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/OracleMappingManagerImpl.java 2023-05-12 20:23:47.245323709 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/mapping/OracleMappingManagerImpl.java 1970-01-01 01:00:00.000000000 +0100
@@ -1,150 +0,0 @@
-/******************************************************************
-Copyright (c) 2004 Erik Bengtson and others. All rights reserved.
-Licensed 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
-
- http://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.
-
-Contributors:
-2004 Andy Jefferson - moved getMapping() from OracleDatabaseAdapter
-2005 Andy Jefferson - changed to extend RDBMSMappingManager
-2006 Andy Jefferson - added override mapping classes method
-2006 Andy Jefferson - moved all mappings to plugin.xml
-2007 Thomas Marti - added BLOB handling
- ...
-*****************************************************************/
-package org.datanucleus.store.rdbms.mapping;
-
-import org.datanucleus.metadata.AbstractMemberMetaData;
-import org.datanucleus.metadata.ElementMetaData;
-import org.datanucleus.metadata.FieldRole;
-import org.datanucleus.metadata.KeyMetaData;
-import org.datanucleus.metadata.ValueMetaData;
-import org.datanucleus.store.rdbms.RDBMSStoreManager;
-import org.datanucleus.store.rdbms.mapping.java.ArrayMapping;
-import org.datanucleus.store.rdbms.mapping.java.BitSetMapping;
-import org.datanucleus.store.rdbms.mapping.java.CollectionMapping;
-import org.datanucleus.store.rdbms.mapping.java.JavaTypeMapping;
-import org.datanucleus.store.rdbms.mapping.java.MapMapping;
-import org.datanucleus.store.rdbms.mapping.java.OracleArrayMapping;
-import org.datanucleus.store.rdbms.mapping.java.OracleBitSetMapping;
-import org.datanucleus.store.rdbms.mapping.java.OracleCollectionMapping;
-import org.datanucleus.store.rdbms.mapping.java.OracleMapMapping;
-import org.datanucleus.store.rdbms.mapping.java.OracleSerialisedObjectMapping;
-import org.datanucleus.store.rdbms.mapping.java.OracleSerialisedPCMapping;
-import org.datanucleus.store.rdbms.mapping.java.OracleStringLobMapping;
-import org.datanucleus.store.rdbms.mapping.java.SerialisedMapping;
-import org.datanucleus.store.rdbms.mapping.java.SerialisedPCMapping;
-import org.datanucleus.store.rdbms.mapping.java.StringMapping;
-
-/**
- * Mapping manager implementation for Oracle datastores.
- * Overrides some of the mappings in the default MappingManager implementation to allow for Oracle strangeness on BLOB/CLOB Handling.
- */
-public class OracleMappingManagerImpl extends MappingManagerImpl
-{
- /**
- * Constructor for a mapping manager for an ORM datastore.
- * @param storeMgr The StoreManager
- */
- public OracleMappingManagerImpl(RDBMSStoreManager storeMgr)
- {
- super(storeMgr);
- }
-
- /**
- * Method to allow overriding of mapping classes. Allows us to configure Oracle-specific non-standard BLOB handling.
- * @param mappingClass The mapping class
- * @param mmd Field meta data for the field (if appropriate)
- * @param fieldRole Role of this column for the field (e.g collection element)
- * @return The mapping class to use
- */
- @Override
- protected Class<? extends JavaTypeMapping> getOverrideMappingClass(Class<? extends JavaTypeMapping> mappingClass, AbstractMemberMetaData mmd, FieldRole fieldRole)
- {
- // Override some mappings with Oracle-specific mappings
- if (mappingClass.equals(BitSetMapping.class))
- {
- return OracleBitSetMapping.class;
- }
- else if (mappingClass.equals(StringMapping.class))
- {
- // Convert into OracleStringMapping if storing the string as a BLOB/CLOB somewhere
- String jdbcType = null;
- if (fieldRole == FieldRole.ROLE_COLLECTION_ELEMENT ||
- fieldRole == FieldRole.ROLE_ARRAY_ELEMENT)
- {
- ElementMetaData elemmd = (mmd != null ? mmd.getElementMetaData() : null);
- if (elemmd != null && elemmd.getColumnMetaData() != null && elemmd.getColumnMetaData().length > 0)
- {
- jdbcType = elemmd.getColumnMetaData()[0].getJdbcTypeName();
- }
- }
- else if (fieldRole == FieldRole.ROLE_MAP_KEY)
- {
- KeyMetaData keymd = (mmd != null ? mmd.getKeyMetaData() : null);
- if (keymd != null && keymd.getColumnMetaData() != null && keymd.getColumnMetaData().length > 0)
- {
- jdbcType = keymd.getColumnMetaData()[0].getJdbcTypeName();
- }
- }
- else if (fieldRole == FieldRole.ROLE_MAP_VALUE)
- {
- ValueMetaData valmd = (mmd != null ? mmd.getValueMetaData() : null);
- if (valmd != null && valmd.getColumnMetaData() != null && valmd.getColumnMetaData().length > 0)
- {
- jdbcType = valmd.getColumnMetaData()[0].getJdbcTypeName();
- }
- }
- else
- {
- if (mmd != null && mmd.getColumnMetaData() != null && mmd.getColumnMetaData().length > 0)
- {
- jdbcType = mmd.getColumnMetaData()[0].getJdbcTypeName();
- }
- }
-
- if (jdbcType != null)
- {
- String jdbcTypeLower = jdbcType.toLowerCase();
- if (jdbcTypeLower.indexOf("blob") >= 0 || jdbcTypeLower.indexOf("clob") >= 0)
- {
- // BLOB/CLOB, so use OracleString
- return OracleStringLobMapping.class;
- }
- }
- return mappingClass;
- }
- else if (mappingClass.equals(SerialisedMapping.class))
- {
- return OracleSerialisedObjectMapping.class;
- }
- else if (mappingClass.equals(SerialisedPCMapping.class))
- {
- return OracleSerialisedPCMapping.class;
- }
- else if (mappingClass.equals(ArrayMapping.class))
- {
- return OracleArrayMapping.class;
- }
- else if (mappingClass.equals(MapMapping.class))
- {
- return OracleMapMapping.class;
- }
- else if (mappingClass.equals(CollectionMapping.class))
- {
- return OracleCollectionMapping.class;
- }
- else
- {
- return mappingClass;
- }
- }
-}
\ No newline at end of file
--- datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/sql/expression/SQLExpressionFactory.java 2023-05-12 20:23:47.257323727 +0200
+++ datanucleus-rdbms-6.0.4/src/main/java/org/datanucleus/store/rdbms/sql/expression/SQLExpressionFactory.java 2023-05-12 20:24:05.125352058 +0200
@@ -160,7 +160,6 @@
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.EnumMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.EnumExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.NumberMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.NumericExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.StringMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.StringExpression.class);
- expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OracleStringLobMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.StringExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OptionalMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.OptionalExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.DateMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.TemporalExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.SqlDateMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.TemporalExpression.class);
@@ -169,12 +168,9 @@
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.GregorianCalendarMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.TemporalExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.ArrayMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.ArrayExpression.class);
- expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OracleArrayMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.ArrayExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.CollectionMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.CollectionExpression.class);
- expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OracleCollectionMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.CollectionExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.SingleCollectionMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.SingleCollectionExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.MapMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.MapExpression.class);
- expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OracleMapMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.MapExpression.class);
expressionClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.DiscriminatorMapping.DiscriminatorLongMapping.class.getName(),
org.datanucleus.store.rdbms.sql.expression.NumericExpression.class);
@@ -215,7 +211,6 @@
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.EnumMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.EnumLiteral.class);
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.NumberMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.FloatingPointLiteral.class);
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.StringMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.StringLiteral.class);
- literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OracleStringLobMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.StringLiteral.class);
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OptionalMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.OptionalLiteral.class);
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.DateMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.TemporalLiteral.class);
@@ -225,12 +220,9 @@
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.GregorianCalendarMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.TemporalLiteral.class);
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.ArrayMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.ArrayLiteral.class);
- literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OracleArrayMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.ArrayLiteral.class);
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.CollectionMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.CollectionLiteral.class);
- literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OracleCollectionMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.CollectionLiteral.class);
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.SingleCollectionMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.SingleCollectionLiteral.class);
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.MapMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.MapLiteral.class);
- literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.OracleMapMapping.class.getName(), org.datanucleus.store.rdbms.sql.expression.MapLiteral.class);
literalClassByMappingName.put(org.datanucleus.store.rdbms.mapping.java.DiscriminatorMapping.DiscriminatorLongMapping.class.getName(),
org.datanucleus.store.rdbms.sql.expression.IntegerLiteral.class);