Class BaseDatastoreAdapter
- All Implemented Interfaces:
DatastoreAdapter
- Direct Known Subclasses:
CloudSpannerAdapter, DB2Adapter, DerbyAdapter, FirebirdAdapter, H2Adapter, HSQLAdapter, InformixAdapter, MySQLAdapter, NuoDBAdapter, PointbaseAdapter, PostgreSQLAdapter, SAPDBAdapter, SQLAnywhereAdapter, SQLiteAdapter, SQLServerAdapter, SybaseAdapter, TimesTenAdapter, VirtuosoAdapter
Each database adapter corresponds to a particular combination of database, database version, driver, and driver version, as provided by the driver's
own metadata. Database adapters cannot be constructed directly, but must be obtained using the DatastoreAdapterFactory class.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe String used to separate catalog and table name.protected intThe major version number of the underlying datastore.protected intThe minor version number of the underlying datastore.protected StringThe product name of the underlying datastore.protected StringThe version number of the underlying datastore as a string.protected intThe revision version number of the underlying datastore.(package private) Map<String, BaseDatastoreAdapter.ColumnTypeMappings> Definition of which datastore mapping should be used for which java type, JDBC type, and SQL type, and the respective default type.protected intThe major version number of the underlying driver.protected intThe minor version number of the underlying driver.protected Stringthe JDBC driver nameprotected Stringthe JDBC driver versionprotected StringThe String used to quote identifiers.static final intThe maximum length of a SQL/92 identifier in characters.protected intThe maximum length to be used for a column name.protected intThe maximum length to be used for a table constraint name.protected intThe maximum length to be used for an index name.protected intThe maximum length to be used for a table name.static final StringA string containing the list of SQL/92 non-reserved words, separated by commas.The set of reserved keywords for this datastore.static final StringA string containing the list of SQL/2003 reserved words, separated by commas.static final StringA string containing the list of SQL/92 reserved words, separated by commas.static final StringA string containing the list of SQL/99 reserved words, separated by commas.protected Collection<String> Supported option names.Fields inherited from interface DatastoreAdapter
ACCESS_PARENTQUERY_IN_SUBQUERY_JOINED, ALTER_TABLE_DROP_CONSTRAINT_SYNTAX, ALTER_TABLE_DROP_FOREIGN_KEY_CONSTRAINT, ANSI_CROSSJOIN_SYNTAX, ANSI_JOIN_SYNTAX, BIT_IS_REALLY_BOOLEAN, BLOB_SET_USING_SETSTRING, BOOLEAN_COMPARISON, CATALOGS_IN_TABLE_DEFINITIONS, CHAR_COLUMNS_PADDED_WITH_SPACES, CHECK_IN_CREATE_STATEMENTS, CHECK_IN_END_CREATE_STATEMENTS, CLOB_SET_USING_SETSTRING, COLUMN_LENGTH_SEMANTICS, CREATE_INDEX_COLUMN_ORDERING, CREATE_INDEXES_BEFORE_FOREIGN_KEYS, CROSSJOIN_ASINNER11_SYNTAX, DATETIME_STORES_MILLISECS, DEFAULT_BEFORE_NULL_IN_COLUMN_OPTIONS, DEFAULT_KEYWORD_IN_COLUMN_OPTIONS, DEFAULT_KEYWORD_WITH_NOT_NULL_IN_COLUMN_OPTIONS, DEFERRED_CONSTRAINTS, DISTINCT_WITH_SELECT_FOR_UPDATE, ESCAPE_EXPRESSION_IN_LIKE_PREDICATE, EXISTS_SYNTAX, FK_DELETE_ACTION_CASCADE, FK_DELETE_ACTION_DEFAULT, FK_DELETE_ACTION_NULL, FK_DELETE_ACTION_RESTRICT, FK_IN_END_CREATE_STATEMENTS, FK_UPDATE_ACTION_CASCADE, FK_UPDATE_ACTION_DEFAULT, FK_UPDATE_ACTION_NULL, FK_UPDATE_ACTION_RESTRICT, GET_GENERATED_KEYS_STATEMENT, GROUP_BY_REQUIRES_ALL_SELECT_PRIMARIES, GROUPING_WITH_SELECT_FOR_UPDATE, HAVING_WITH_SELECT_FOR_UPDATE, HOLD_CURSORS_OVER_COMMIT, IDENTIFIERS_LOWERCASE, IDENTIFIERS_LOWERCASE_QUOTED, IDENTIFIERS_MIXEDCASE, IDENTIFIERS_MIXEDCASE_QUOTED, IDENTIFIERS_MIXEDCASE_QUOTED_SENSITIVE, IDENTIFIERS_MIXEDCASE_SENSITIVE, IDENTIFIERS_UPPERCASE, IDENTIFIERS_UPPERCASE_QUOTED, IDENTITY_COLUMN_TYPE_SPECIFICATION, IDENTITY_COLUMNS, IDENTITY_KEYS_NULL_SPECIFICATION, IDENTITY_PK_IN_CREATE_TABLE_COLUMN_DEF, INCLUDE_ORDERBY_COLS_IN_SELECT, INCLUDE_TABLE_INDEX_STATISTICS, LOCK_ROW_USING_OPTION_AFTER_FROM, LOCK_ROW_USING_OPTION_WITHIN_JOIN, LOCK_ROW_USING_SELECT_FOR_UPDATE, LOCK_ROW_USING_SELECT_FOR_UPDATE_NOWAIT, MULTITABLES_WITH_SELECT_FOR_UPDATE, NATIVE_ENUM_TYPE, NULL_EQUALS_EMPTY_STRING, NULLS_IN_CANDIDATE_KEYS, NULLS_KEYWORD_IN_COLUMN_OPTIONS, OPERATOR_BITWISE_AND, OPERATOR_BITWISE_OR, OPERATOR_BITWISE_XOR, ORDERBY_NULLS_DIRECTIVES, ORDERBY_NULLS_USING_CASE_NULL, ORDERBY_NULLS_USING_COLUMN_IS_NULL, ORDERBY_NULLS_USING_ISNULL, ORDERBY_USING_SELECT_COLUMN_INDEX, ORDERING_WITH_SELECT_FOR_UPDATE, PARAMETER_IN_CASE_IN_UPDATE_CLAUSE, PERSIST_OF_UNASSIGNED_CHAR, PRIMARYKEY_IN_CREATE_STATEMENTS, PROJECTION_IN_TABLE_REFERENCE_JOINS, RAW_PREFIX_LIKE_STATEMENTS, RESULTSET_TYPE_FORWARD_ONLY, RESULTSET_TYPE_SCROLL_INSENSITIVE, RESULTSET_TYPE_SCROLL_SENSITIVE, RIGHT_OUTER_JOIN, SCHEMAS_IN_TABLE_DEFINITIONS, SEQUENCES, SOME_ANY_ALL_SUBQUERY_EXPRESSIONS, STATEMENT_BATCHING, STORED_PROCEDURES, SUBQUERY_IN_HAVING, TX_ISOLATION_NONE, TX_ISOLATION_READ_COMMITTED, TX_ISOLATION_READ_UNCOMMITTED, TX_ISOLATION_REPEATABLE_READ, TX_ISOLATION_SERIALIZABLE, UNION_SYNTAX, UNIQUE_IN_END_CREATE_STATEMENTS, UPDATE_DELETE_STATEMENT_ALLOW_TABLE_ALIAS_IN_WHERE_CLAUSE, UPDATE_STATEMENT_ALLOW_TABLE_ALIAS_IN_SET_CLAUSE, USE_UNION_ALL, VALUE_GENERATION_UUID_STRING, VIEWS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseDatastoreAdapter(DatabaseMetaData metadata) Constructs a database adapter based on the given JDBC metadata. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaddSQLTypeForJDBCType(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn, short jdbcTypeNumber, SQLTypeInfo sqlType, boolean addIfNotPresent) Convenience method for use by adapters to add their own fake JDBC/SQL types in where the JDBC driver doesn't provide some type.voidderegisterColumnMappingsForJDBCType(String jdbcTypeName) Utility to deregister all datastore mappings for a JDBC type.longgetAdapterTime(Timestamp time) Utility to return the adapter time in case there are rounding issues with millisecs etc.getAddCandidateKeyStatement(CandidateKey ck, IdentifierFactory factory) Returns the appropriate SQL to add a candidate key to its table.getAddColumnStatement(Table table, Column col) Accessor for the SQL statement to add a column to a table.getAddForeignKeyStatement(ForeignKey fk, IdentifierFactory factory) Returns the appropriate SQL to add a foreign key to its table.getAddPrimaryKeyStatement(PrimaryKey pk, IdentifierFactory factory) Returns the appropriate SQL to add a primary key to its table.getCatalogName(Connection conn) Accessor for the Catalog Name for this datastore.Accessor for the catalog separator.getCheckConstraintForValues(DatastoreIdentifier identifier, Object[] values, boolean nullable) Creates a CHECK constraint definition based on the given values e.g.Class<? extends ColumnMapping> getColumnMappingClass(String javaType, String jdbcType, String sqlType, org.datanucleus.ClassLoaderResolver clr, String fieldName) Accessor for a datastore mapping class for the specified java type (and optional jdbc-type or sql-type).getColumns(Connection conn, String catalog, String schema, String tableNamePattern, String columnNamePattern) Accessor for table and column information for a catalog/schema in this datastore.Continuation string to use where the SQL statement goes over more than 1 line.getCreateDatabaseStatement(String catalogName, String schemaName) Method to return the statement necessary to create a database with this RDBMS.getCreateIndexStatement(Index idx, IdentifierFactory factory) Returns the appropriate DDL to create an index.getCreateTableStatement(TableImpl table, Column[] columns, Properties props, IdentifierFactory factory) Returns the appropriate SQL to create the given table having the given columns.Accessor for a statement that will return the statement to use to get the datastore date.Accessor for the datastore driver name.Accessor for the datastore driver version.intgetDatastoreIdentifierMaxLength(IdentifierType identifierType) Method to return the maximum length of a datastore identifier of the specified type.Accessor for the datastore product name.Accessor for the datastore product version.getDefaultSqlTypeForJavaType(String javaType, String jdbcType) Method to return the default sql-type for the specified java type (and JDBC type)Method to return the basic SQL for a DELETE TABLE statement.intAccessor for the JDBC driver major versionintAccessor for the JDBC driver minor versiongetDropDatabaseStatement(String catalogName, String schemaName) Method to return the statement necessary to drop a database with this RDBMS.getDropTableStatement(Table table) Returns the appropriate SQL to drop the given table.getDropViewStatement(ViewImpl view) Returns the appropriate SQL to drop the given view.The character for escaping characters in pattern expressions.The character for escaping characters in pattern expressions.getExistingIndexes(Connection conn, String catalog, String schema, String table) Provide the existing indexes in the database for the table.Accessor for an identifier quote string.Return the java type that represents any identity (autoincrement) column value.getIdentityKeyword(org.datanucleus.store.StoreManager storeMgr) Accessor for the autoincrementing keyword for generating DDLs (CREATE TABLEs...).getIdentityLastValueStmt(Table table, String columnName) Accessor for the autoincrementing sql statement for this datastore.Method to return the INSERT statement to use when inserting into a table that has no columns specified.intgetJDBCTypeForName(String typeName) Method to return the type given the "jdbc-type" name.getMappingManager(RDBMSStoreManager storeMgr) Accessor for a MappingManager suitable for use with this datastore adapter.intAccessor for the maximum foreign keys by table permitted for this datastore.intAccessor for the maximum indexes by schema permitted for this datastore.protected intgetMiliseconds(long nanos) getNameForJDBCType(int jdbcType) Return a name for a JDBC Types value.The function to creates a unique value of type uniqueidentifier.Accessor for the function to use for converting to numeric.getOrderString(org.datanucleus.store.StoreManager storeMgr, String orderString, SQLExpression sqlExpr) Convenience method to allow adaption of an ordering string before applying it.The pattern string for representing one character that is expanded in word searches.The pattern string for representing zero or more characters that is expanded in word searches.getPreferredDefaultSQLTypeForJDBCType(org.datanucleus.metadata.JdbcType jdbcType) Way for a DatastoreAdapter to specify a preferred default SQL type for a JDBC type (when there are multiple).getRangeByLimitEndOfStatementClause(long offset, long count, boolean hasOrdering) Method to return the SQL to append to the end of the SELECT statement to handle restriction of ranges using the LIMIT keyword.Method to return the column name to use when handling ranges via a row-number on the select using the original method (DB2).Method to return the column name to use when handling ranges via a rownumber on the select using the second method (Oracle).intAccessor for the "required" transaction isolation level if it has to be a certain value for this adapter.Accessor for the reserved words constructed from the method DataBaseMetaData.getSQLKeywords + standard SQL reserved wordsgetSchemaName(Connection conn) Accessor for the Schema Name for this datastore.Method returning the text to append to the end of the SELECT to perform the equivalent of "SELECT ...The function to creates a unique value of type uniqueidentifier.The option to specify in "SELECT ...getSequenceCreateStmt(String sequence_name, Integer min, Integer max, Integer start, Integer increment, Integer cache_size) Accessor for the sequence create statement for this datastore.getSequenceNextStmt(String sequence_name) Accessor for the sequence statement to get the next id for this datastore.getSQLMethodClass(String className, String methodName, org.datanucleus.ClassLoaderResolver clr) Accessor for the SQLMethod class for the query invocation of specified class + method name (if available for this datastore).Class<? extends SQLOperation> getSQLOperationClass(String operationName) Accessor for the SQLOperation class for the specified operation (if available for this datastore).protected Collection<SQLTypeInfo> getSQLTypeInfoForJdbcType(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn, short jdbcTypeNumber) Accessor for the SQLType info for the specified JDBC type and the SQL type name.Accessor for the options that are supported by this datastore adapter and the underlying datastore.Some databases, Oracle, treats an empty string (0 length) equals nullprotected longgetTime(long time, long nanos) intAccessor for the transaction isolation level to use during schema creation.intgetUnlimitedLengthPrecisionValue(SQLTypeInfo typeInfo) Returns the precision value to be used when creating string columns of "unlimited" length.getUpdateTableStatement(SQLTable tbl, SQLText setSQL) Method to return the SQLText for an UPDATE TABLE statement.Accessor for the Vendor ID for this datastore.voidinitialise(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn) Initialise the datastore adapter.voidCreates the auxiliary functions/procedures in the schemavoidinitialiseTypes(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn) Initialise the types for this datastore.booleanisIdentityFieldDataType(String typeName) Verifies if the giventypeNameis auto incremented by the datastore.booleanisReservedKeyword(String word) Tests if a given string is an SQL keyword.booleanreturn whether this exception represents a cancelled statement.booleanreturn whether this exception represents a timed out statement.booleanisValidPrimaryKeyType(org.datanucleus.metadata.JdbcType datatype) Method to return whether the specified JDBC type is valid for use in a PrimaryKey.protected voidloadColumnMappings(org.datanucleus.plugin.PluginManager pluginMgr, org.datanucleus.ClassLoaderResolver clr) Load all column mappings defined in the associated plugins via the plugin mechanism.Method to return ForeignKeyInfo for the current row of the ResultSet which will have been obtained from a call to DatabaseMetaData.getImportedKeys() or DatabaseMetaData.getExportedKeys().Create a new column info from the current row of the passed ResultSet.Create a new SQL type info from the current row of the passed ResultSet.voidregisterColumnMapping(String javaTypeName, Class<? extends ColumnMapping> columnMappingType, String jdbcType, String sqlType, boolean dflt) Method to register a column mapping for a specified java type, and against particular JDBC/SQL type.voidregisterColumnMapping(String javaTypeName, Class<? extends ColumnMapping> columnMappingType, JDBCType jdbcType, String sqlType, boolean dflt) booleansequenceExists(Connection conn, String catalogName, String schemaName, String seqName) Convenience method to return whether the specified sequence already exists.booleansupportsOption(String option) Accessor for whether the supplied option is supported.booleansupportsQueryFetchSize(int size) Whether the datastore will support setting the query fetch size to the supplied value.booleansupportsTransactionIsolation(int level) Accessor for whether this database adapter supports the specified transaction isolation.toString()Method to return this object as a string.booleanvalidToIndexMapping(JavaTypeMapping mapping) Method to return whether the specified mapping is indexable.booleanMethod to return if it is valid to select the specified mapping for the specified statement for this datastore adapter.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface DatastoreAdapter
getIdentityKeyword
-
Field Details
-
MAX_IDENTIFIER_LENGTH
public static final int MAX_IDENTIFIER_LENGTHThe maximum length of a SQL/92 identifier in characters.- See Also:
-
SQL92_RESERVED_WORDS
A string containing the list of SQL/92 reserved words, separated by commas.- See Also:
-
SQL99_RESERVED_WORDS
A string containing the list of SQL/99 reserved words, separated by commas.- See Also:
-
SQL2003_RESERVED_WORDS
A string containing the list of SQL/2003 reserved words, separated by commas.- See Also:
-
NONRESERVED_WORDS
A string containing the list of SQL/92 non-reserved words, separated by commas.- See Also:
-
supportedJdbcTypesById
-
unsupportedJdbcTypesById
-
reservedKeywords
-
datastoreProductName
The product name of the underlying datastore. -
datastoreProductVersion
The version number of the underlying datastore as a string. -
datastoreMajorVersion
protected int datastoreMajorVersionThe major version number of the underlying datastore. -
datastoreMinorVersion
protected int datastoreMinorVersionThe minor version number of the underlying datastore. -
datastoreRevisionVersion
protected int datastoreRevisionVersionThe revision version number of the underlying datastore. -
identifierQuoteString
The String used to quote identifiers. -
supportedOptions
Supported option names. -
driverName
the JDBC driver name -
driverVersion
the JDBC driver version -
driverMajorVersion
protected int driverMajorVersionThe major version number of the underlying driver. -
driverMinorVersion
protected int driverMinorVersionThe minor version number of the underlying driver. -
maxTableNameLength
protected int maxTableNameLengthThe maximum length to be used for a table name. -
maxConstraintNameLength
protected int maxConstraintNameLengthThe maximum length to be used for a table constraint name. -
maxIndexNameLength
protected int maxIndexNameLengthThe maximum length to be used for an index name. -
maxColumnNameLength
protected int maxColumnNameLengthThe maximum length to be used for a column name. -
catalogSeparator
The String used to separate catalog and table name. -
datastoreTypeMappingsByJavaType
Map<String, BaseDatastoreAdapter.ColumnTypeMappings> datastoreTypeMappingsByJavaTypeDefinition of which datastore mapping should be used for which java type, JDBC type, and SQL type, and the respective default type.
-
-
Constructor Details
-
BaseDatastoreAdapter
Constructs a database adapter based on the given JDBC metadata.- Parameters:
metadata- the database metadata.
-
-
Method Details
-
initialise
public void initialise(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn) Description copied from interface:DatastoreAdapterInitialise the datastore adapter.- Specified by:
initialisein interfaceDatastoreAdapter- Parameters:
handler- SchemaHandler that we initialise the types formconn- Managed connection to use
-
initialiseTypes
public void initialiseTypes(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn) Initialise the types for this datastore.- Specified by:
initialiseTypesin interfaceDatastoreAdapter- Parameters:
handler- SchemaHandler that we initialise the types formconn- Managed connection to use
-
initialiseDatastore
Creates the auxiliary functions/procedures in the schema- Specified by:
initialiseDatastorein interfaceDatastoreAdapter- Parameters:
conn- the connection to the datastore
-
getPreferredDefaultSQLTypeForJDBCType
Description copied from interface:DatastoreAdapterWay for a DatastoreAdapter to specify a preferred default SQL type for a JDBC type (when there are multiple).- Specified by:
getPreferredDefaultSQLTypeForJDBCTypein interfaceDatastoreAdapter- Parameters:
jdbcType- The JDBC type- Returns:
- The SQL type preferred
-
getNameForJDBCType
Description copied from interface:DatastoreAdapterReturn a name for a JDBC Types value.- Specified by:
getNameForJDBCTypein interfaceDatastoreAdapter- Parameters:
jdbcType- The jdbc type- Returns:
- The name
-
getJDBCTypeForName
Description copied from interface:DatastoreAdapterMethod to return the type given the "jdbc-type" name.- Specified by:
getJDBCTypeForNamein interfaceDatastoreAdapter- Parameters:
typeName- "jdbc-type" name- Returns:
- Whether it is valid
-
getSQLTypeInfoForJdbcType
protected Collection<SQLTypeInfo> getSQLTypeInfoForJdbcType(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn, short jdbcTypeNumber) Accessor for the SQLType info for the specified JDBC type and the SQL type name.- Parameters:
handler- Schema handlermconn- ConnectionjdbcTypeNumber- JDBC type- Returns:
- The SQL type info
-
addSQLTypeForJDBCType
protected boolean addSQLTypeForJDBCType(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn, short jdbcTypeNumber, SQLTypeInfo sqlType, boolean addIfNotPresent) Convenience method for use by adapters to add their own fake JDBC/SQL types in where the JDBC driver doesn't provide some type.- Parameters:
handler- the schema handler managing the typesmconn- Connection to usejdbcTypeNumber- The JDBC typesqlType- The type info to useaddIfNotPresent- whether to add only if JDBC type not present- Returns:
- Whether the SQL type for JDBC type was added
-
supportsTransactionIsolation
public boolean supportsTransactionIsolation(int level) Accessor for whether this database adapter supports the specified transaction isolation.- Specified by:
supportsTransactionIsolationin interfaceDatastoreAdapter- Parameters:
level- The isolation level (as defined by Connection enums).- Returns:
- Whether it is supported.
-
getSupportedOptions
Accessor for the options that are supported by this datastore adapter and the underlying datastore.- Specified by:
getSupportedOptionsin interfaceDatastoreAdapter- Returns:
- The options (Collection<String>)
-
supportsOption
Accessor for whether the supplied option is supported.- Specified by:
supportsOptionin interfaceDatastoreAdapter- Parameters:
option- The option- Returns:
- Whether supported.
-
getMappingManager
Accessor for a MappingManager suitable for use with this datastore adapter.- Specified by:
getMappingManagerin interfaceDatastoreAdapter- Parameters:
storeMgr- The StoreManager- Returns:
- the MappingManager
-
getAdapterTime
Description copied from interface:DatastoreAdapterUtility to return the adapter time in case there are rounding issues with millisecs etc.- Specified by:
getAdapterTimein interfaceDatastoreAdapter- Parameters:
time- The timestamp- Returns:
- The time in millisecs
-
getTime
protected long getTime(long time, long nanos) -
getMiliseconds
protected int getMiliseconds(long nanos) -
getDatastoreProductName
Description copied from interface:DatastoreAdapterAccessor for the datastore product name.- Specified by:
getDatastoreProductNamein interfaceDatastoreAdapter- Returns:
- product name
-
getDatastoreProductVersion
Description copied from interface:DatastoreAdapterAccessor for the datastore product version.- Specified by:
getDatastoreProductVersionin interfaceDatastoreAdapter- Returns:
- product version
-
getDatastoreDriverName
Description copied from interface:DatastoreAdapterAccessor for the datastore driver name.- Specified by:
getDatastoreDriverNamein interfaceDatastoreAdapter- Returns:
- product name
-
getDatastoreDriverVersion
Description copied from interface:DatastoreAdapterAccessor for the datastore driver version.- Specified by:
getDatastoreDriverVersionin interfaceDatastoreAdapter- Returns:
- driver version
-
supportsQueryFetchSize
public boolean supportsQueryFetchSize(int size) Whether the datastore will support setting the query fetch size to the supplied value.- Specified by:
supportsQueryFetchSizein interfaceDatastoreAdapter- Parameters:
size- The value to set to- Returns:
- Whether it is supported.
-
getVendorID
Description copied from interface:DatastoreAdapterAccessor for the Vendor ID for this datastore.- Specified by:
getVendorIDin interfaceDatastoreAdapter- Returns:
- Vendor id for this datastore
-
isReservedKeyword
Tests if a given string is an SQL keyword.The list of key words tested against is defined to contain all SQL/92 keywords, plus any additional key words reported by the JDBC driver for this adapter via
DatabaseMetaData.getSQLKeywords().In general, use of a SQL key word as an identifier should be avoided. SQL/92 key words are divided into reserved and non-reserved words. If a reserved word is used as an identifier it must be quoted with double quotes. Strictly speaking, the same is not true of non-reserved words. However, as C.J. Date writes in A Guide To The SQL Standard :
The rule by which it is determined within the standard that one key word needs to be reserved while another need not is not clear to this writer. In practice, it is probably wise to treat all key words as reserved.
- Specified by:
isReservedKeywordin interfaceDatastoreAdapter- Parameters:
word- The word to test.- Returns:
trueif word is a SQL key word for this DBMS. The comparison is case-insensitive.
-
getIdentifierQuoteString
Accessor for an identifier quote string.- Specified by:
getIdentifierQuoteStringin interfaceDatastoreAdapter- Returns:
- Identifier quote string.
-
getDriverMajorVersion
public int getDriverMajorVersion()Accessor for the JDBC driver major version- Specified by:
getDriverMajorVersionin interfaceDatastoreAdapter- Returns:
- The driver major version
-
getDriverMinorVersion
public int getDriverMinorVersion()Accessor for the JDBC driver minor version- Specified by:
getDriverMinorVersionin interfaceDatastoreAdapter- Returns:
- The driver minor version
-
getDatastoreIdentifierMaxLength
Method to return the maximum length of a datastore identifier of the specified type. If no limit exists then returns -1- Specified by:
getDatastoreIdentifierMaxLengthin interfaceDatastoreAdapter- Parameters:
identifierType- Type of identifier (see IdentifierFactory.TABLE, etc)- Returns:
- The max permitted length of this type of identifier
-
getMaxForeignKeys
public int getMaxForeignKeys()Accessor for the maximum foreign keys by table permitted for this datastore.- Specified by:
getMaxForeignKeysin interfaceDatastoreAdapter- Returns:
- Max number of FKs for a table
-
getMaxIndexes
public int getMaxIndexes()Accessor for the maximum indexes by schema permitted for this datastore.- Specified by:
getMaxIndexesin interfaceDatastoreAdapter- Returns:
- Max number of indexes for a table
-
getReservedWords
Accessor for the reserved words constructed from the method DataBaseMetaData.getSQLKeywords + standard SQL reserved words- Specified by:
getReservedWordsin interfaceDatastoreAdapter- Returns:
- Set of reserved words
-
newRDBMSColumnInfo
Description copied from interface:DatastoreAdapterCreate a new column info from the current row of the passed ResultSet. Allows an adapter to override particular column information where the JDBC driver is known to be buggy.- Specified by:
newRDBMSColumnInfoin interfaceDatastoreAdapter- Parameters:
rs- Result Set- Returns:
- The column info
-
newSQLTypeInfo
Description copied from interface:DatastoreAdapterCreate a new SQL type info from the current row of the passed ResultSet. Allows an adapter to override particular types where the JDBC driver is known to be buggy.- Specified by:
newSQLTypeInfoin interfaceDatastoreAdapter- Parameters:
rs- ResultSet- Returns:
- The SQL type info
-
newFKInfo
Method to return ForeignKeyInfo for the current row of the ResultSet which will have been obtained from a call to DatabaseMetaData.getImportedKeys() or DatabaseMetaData.getExportedKeys().- Specified by:
newFKInfoin interfaceDatastoreAdapter- Parameters:
rs- The result set returned from DatabaseMetaData.get??portedKeys()- Returns:
- The foreign key info
-
getUnlimitedLengthPrecisionValue
Returns the precision value to be used when creating string columns of "unlimited" length. Usually, if this value is needed it is provided in. However, for some types in some databases the value must be computed.- Specified by:
getUnlimitedLengthPrecisionValuein interfaceDatastoreAdapter- Parameters:
typeInfo- the typeInfo object for which the precision value is needed.- Returns:
- the precision value to be used when creating the column, or -1 if no value should be used.
-
isValidPrimaryKeyType
public boolean isValidPrimaryKeyType(org.datanucleus.metadata.JdbcType datatype) Method to return whether the specified JDBC type is valid for use in a PrimaryKey.- Specified by:
isValidPrimaryKeyTypein interfaceDatastoreAdapter- Parameters:
datatype- The JDBC type.- Returns:
- Whether it is valid for use in the PK
-
getSurrogateForEmptyStrings
Some databases, Oracle, treats an empty string (0 length) equals null- Specified by:
getSurrogateForEmptyStringsin interfaceDatastoreAdapter- Returns:
- returns a surrogate to replace the empty string in the database otherwise it would be treated as null
-
getTransactionIsolationForSchemaCreation
public int getTransactionIsolationForSchemaCreation()Accessor for the transaction isolation level to use during schema creation.- Specified by:
getTransactionIsolationForSchemaCreationin interfaceDatastoreAdapter- Returns:
- The transaction isolation level for schema generation process
-
getRequiredTransactionIsolationLevel
public int getRequiredTransactionIsolationLevel()Accessor for the "required" transaction isolation level if it has to be a certain value for this adapter.- Specified by:
getRequiredTransactionIsolationLevelin interfaceDatastoreAdapter- Returns:
- Transaction isolation level (-1 implies no restriction)
-
getCatalogName
Accessor for the Catalog Name for this datastore.- Specified by:
getCatalogNamein interfaceDatastoreAdapter- Parameters:
conn- Connection to the datastore- Returns:
- The catalog name
- Throws:
SQLException- Thrown if error occurs in determining the catalog name.
-
getSchemaName
Accessor for the Schema Name for this datastore.- Specified by:
getSchemaNamein interfaceDatastoreAdapter- Parameters:
conn- Connection to the datastore- Returns:
- The schema name
- Throws:
SQLException- Thrown if error occurs in determining the schema name.
-
getCatalogSeparator
Accessor for the catalog separator.- Specified by:
getCatalogSeparatorin interfaceDatastoreAdapter- Returns:
- Catalog separator string.
-
getSelectWithLockOption
The option to specify in "SELECT ... FROM TABLE ... WITH (option)" to lock instances Returns null if not supported.- Specified by:
getSelectWithLockOptionin interfaceDatastoreAdapter- Returns:
- The option to specify with "SELECT ... FROM TABLE ... WITH (option)"
-
getSelectForUpdateText
Method returning the text to append to the end of the SELECT to perform the equivalent of "SELECT ... FOR UPDATE" (on some RDBMS). This method means that we can have different text with some datastores (e.g Derby).- Specified by:
getSelectForUpdateTextin interfaceDatastoreAdapter- Returns:
- The "FOR UPDATE" text
-
getSelectNewUUIDStmt
The function to creates a unique value of type uniqueidentifier.- Specified by:
getSelectNewUUIDStmtin interfaceDatastoreAdapter- Returns:
- The function. e.g. "SELECT NEWID()"
-
getNewUUIDFunction
The function to creates a unique value of type uniqueidentifier.- Returns:
- The function. e.g. "NEWID()"
-
getOrderString
public String getOrderString(org.datanucleus.store.StoreManager storeMgr, String orderString, SQLExpression sqlExpr) 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.- Specified by:
getOrderStringin interfaceDatastoreAdapter- Parameters:
storeMgr- StoreManagerorderString- The basic ordering stringsqlExpr- The sql expression being represented here- Returns:
- The adapted ordering string
-
validToSelectMappingInStatement
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.- Specified by:
validToSelectMappingInStatementin interfaceDatastoreAdapter- Parameters:
stmt- The statementm- The mapping that we want to select- Returns:
- Whether it is valid
-
getIdentityLastValueStmt
Accessor for the autoincrementing sql statement for this datastore.- Specified by:
getIdentityLastValueStmtin interfaceDatastoreAdapter- Parameters:
table- Name of the table that the autoincrement is forcolumnName- Name of the column that the autoincrement is for- Returns:
- The statement for getting the latest autoincremented key
-
getIdentityKeyword
Accessor for the autoincrementing keyword for generating DDLs (CREATE TABLEs...).- Specified by:
getIdentityKeywordin interfaceDatastoreAdapter- Parameters:
storeMgr- The Store Manager- Returns:
- The keyword for a column using autoincrement
-
getIdentityJavaTypeForType
Description copied from interface:DatastoreAdapterReturn the java type that represents any identity (autoincrement) column value.- Specified by:
getIdentityJavaTypeForTypein interfaceDatastoreAdapter- Parameters:
type- The type of the member mapping to an IDENTITY column- Returns:
- The type that should be used in generating the column
-
isIdentityFieldDataType
Verifies if the giventypeNameis auto incremented by the datastore.- Specified by:
isIdentityFieldDataTypein interfaceDatastoreAdapter- Parameters:
typeName- the datastore type name- Returns:
- true when the
typeNamehas values auto incremented by the datastore
-
getInsertStatementForNoColumns
Method to return the INSERT statement to use when inserting into a table that has no columns specified. This is the case when we have a single column in the table and that column is autoincrement/identity (and so is assigned automatically in the datastore).- Specified by:
getInsertStatementForNoColumnsin interfaceDatastoreAdapter- Parameters:
table- The table- Returns:
- The statement for the INSERT
-
sequenceExists
public boolean sequenceExists(Connection conn, String catalogName, String schemaName, String seqName) Description copied from interface:DatastoreAdapterConvenience method to return whether the specified sequence already exists.- Specified by:
sequenceExistsin interfaceDatastoreAdapter- Parameters:
conn- Connection to use for checkingcatalogName- Catalog nameschemaName- Schema nameseqName- Name of the sequence- Returns:
- Whether it exists
-
getSequenceCreateStmt
public String getSequenceCreateStmt(String sequence_name, Integer min, Integer max, Integer start, Integer increment, Integer cache_size) Accessor for the sequence create statement for this datastore.- Specified by:
getSequenceCreateStmtin interfaceDatastoreAdapter- Parameters:
sequence_name- Name of the sequencemin- Minimum value for the sequencemax- Maximum value for the sequencestart- Start value for the sequenceincrement- Increment value for the sequencecache_size- Cache size for the sequence- Returns:
- The statement for getting the next id from the sequence
-
getSequenceNextStmt
Accessor for the sequence statement to get the next id for this datastore.- Specified by:
getSequenceNextStmtin interfaceDatastoreAdapter- Parameters:
sequence_name- Name of the sequence- Returns:
- The statement for getting the next id for the sequence
-
getExistingIndexes
public ResultSet getExistingIndexes(Connection conn, String catalog, String schema, String table) throws SQLException 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. Otherwise we will use DatabaseMetaData.getIndexInfo(). The implementation here returns null.- Specified by:
getExistingIndexesin interfaceDatastoreAdapter- Parameters:
conn- the JDBC connectioncatalog- the catalog nameschema- the schema nametable- the table name- Returns:
- 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
-
getCreateTableStatement
public String getCreateTableStatement(TableImpl table, Column[] columns, Properties props, IdentifierFactory factory) Returns the appropriate SQL to create the given table having the given columns. No column constraints or key definitions should be included. It should return something like:CREATE TABLE FOO ( BAR VARCHAR(30), BAZ INTEGER )
- Specified by:
getCreateTableStatementin interfaceDatastoreAdapter- Parameters:
table- The table to create.columns- The columns of the table.props- Properties for controlling the table creationfactory- Factory for identifiers- Returns:
- The text of the SQL statement.
-
getAddPrimaryKeyStatement
Returns the appropriate SQL to add a primary key to its table. It should return something like:ALTER TABLE FOO ADD [CONSTRAINT FOO_PK ]PRIMARY KEY (BAR)
- Specified by:
getAddPrimaryKeyStatementin interfaceDatastoreAdapter- Parameters:
pk- An object describing the primary key.factory- Identifier factory- Returns:
- The text of the SQL statement.
-
getAddCandidateKeyStatement
Returns the appropriate SQL to add a candidate key to its table. It should return something like:ALTER TABLE FOO ADD [CONSTRAINT FOO_CK ]UNIQUE (BAZ)
- Specified by:
getAddCandidateKeyStatementin interfaceDatastoreAdapter- Parameters:
ck- An object describing the candidate key.factory- Identifier factory- Returns:
- The text of the SQL statement.
-
getAddForeignKeyStatement
Returns the appropriate SQL to add a foreign key to its table. It should return something like:ALTER TABLE FOO ADD [CONSTRAINT FOO_FK1 ]FOREIGN KEY (BAR, BAZ) REFERENCES ABC (COL1, COL2)
- Specified by:
getAddForeignKeyStatementin interfaceDatastoreAdapter- Parameters:
fk- An object describing the foreign key.factory- Identifier factory- Returns:
- The text of the SQL statement.
-
getAddColumnStatement
Accessor for the SQL statement to add a column to a table.- Specified by:
getAddColumnStatementin interfaceDatastoreAdapter- Parameters:
table- The tablecol- The column- Returns:
- The SQL necessary to add the column
-
getCreateIndexStatement
Returns the appropriate DDL to create an index. It should return something like:CREATE [UNIQUE ]INDEX FOO_U1 ON FOO (BAR,BAZ) [Extended Settings]
- Specified by:
getCreateIndexStatementin interfaceDatastoreAdapter- Parameters:
idx- An object describing the index.factory- Identifier factory- Returns:
- The text of the SQL statement.
-
getCheckConstraintForValues
public String getCheckConstraintForValues(DatastoreIdentifier identifier, Object[] values, boolean nullable) Creates a CHECK constraint definition based on the given values e.g.CHECK ("COLUMN" IN ('VAL1','VAL2') OR "COLUMN" IS NULL)- Specified by:
getCheckConstraintForValuesin interfaceDatastoreAdapter- Parameters:
identifier- Column identifiervalues- Valid valuesnullable- whether the datastore identifier is null- Returns:
- The check constraint
-
getCreateDatabaseStatement
Description copied from interface:DatastoreAdapterMethod to return the statement necessary to create a database with this RDBMS. Note that some RDBMS don't support this.- Specified by:
getCreateDatabaseStatementin interfaceDatastoreAdapter- Parameters:
catalogName- name of the catalogschemaName- Name of the schema- Returns:
- The DDL statement
-
getDropDatabaseStatement
Description copied from interface:DatastoreAdapterMethod to return the statement necessary to drop a database with this RDBMS. Note that some RDBMS don't support this.- Specified by:
getDropDatabaseStatementin interfaceDatastoreAdapter- Parameters:
catalogName- Name of the catalogschemaName- Name of the schema- Returns:
- The DDL statement
-
getDropTableStatement
Returns the appropriate SQL to drop the given table. It should return something like:DROP TABLE FOO CASCADE
- Specified by:
getDropTableStatementin interfaceDatastoreAdapter- Parameters:
table- The table to drop.- Returns:
- The text of the SQL statement.
-
getDropViewStatement
Returns the appropriate SQL to drop the given view. It should return something like:DROP VIEW FOO
- Specified by:
getDropViewStatementin interfaceDatastoreAdapter- Parameters:
view- The view to drop.- Returns:
- The text of the SQL statement.
-
getDeleteTableStatement
Method to return the basic SQL for a DELETE TABLE statement. Returns the String asDELETE FROM tbl t1. Doesn't include any where clause.- Specified by:
getDeleteTableStatementin interfaceDatastoreAdapter- Parameters:
tbl- The SQLTable to delete- Returns:
- The delete table string
-
getUpdateTableStatement
Method to return the SQLText for an UPDATE TABLE statement. Returns the SQLText forUPDATE tbl t1 SET x1 = val1, x2 = val2. Override if the datastore doesn't support that standard syntax.- Specified by:
getUpdateTableStatementin interfaceDatastoreAdapter- Parameters:
tbl- The primary tablesetSQL- The SQLText for the SET component- Returns:
- SQLText for the update statement
-
getRangeByLimitEndOfStatementClause
Method to return the SQL to append to the end of the SELECT statement to handle restriction of ranges using the LIMIT keyword. Defaults to an empty string (not supported).SELECT param ... WHERE {LIMIT}- Specified by:
getRangeByLimitEndOfStatementClausein interfaceDatastoreAdapter- Parameters:
offset- The offset to return fromcount- The number of items to returnhasOrdering- Whether there is ordering present- Returns:
- The SQL to append to allow for ranges using LIMIT.
-
getRangeByRowNumberColumn
Method to return the column name to use when handling ranges via a row-number on the select using the original method (DB2). Defaults to an empty string (not supported).- Specified by:
getRangeByRowNumberColumnin interfaceDatastoreAdapter- Returns:
- The row number column.
-
getRangeByRowNumberColumn2
Method to return the column name to use when handling ranges via a rownumber on the select using the second method (Oracle). Defaults to an empty string (not supported).- Specified by:
getRangeByRowNumberColumn2in interfaceDatastoreAdapter- Returns:
- The row number column.
-
getColumns
public ResultSet getColumns(Connection conn, String catalog, String schema, String tableNamePattern, String columnNamePattern) throws SQLException Accessor for table and column information for a catalog/schema in this datastore.- Specified by:
getColumnsin interfaceDatastoreAdapter- Parameters:
conn- Connection to usecatalog- The catalog (null if none)schema- The schema (null if none)tableNamePattern- The table name pattern (null if all)columnNamePattern- The column name pattern (null if all)- Returns:
- ResultSet containing the table/column information
- Throws:
SQLException- Thrown if an error occurs
-
toString
Description copied from interface:DatastoreAdapterMethod to return this object as a string.- Specified by:
toStringin interfaceDatastoreAdapter- Overrides:
toStringin classObject- Returns:
- String version of this object.
-
getDatastoreDateStatement
Accessor for a statement that will return the statement to use to get the datastore date.- Specified by:
getDatastoreDateStatementin interfaceDatastoreAdapter- Returns:
- SQL statement to get the datastore date
-
getPatternExpressionAnyCharacter
The pattern string for representing one character that is expanded in word searches. Most of databases will use the underscore character.- Specified by:
getPatternExpressionAnyCharacterin interfaceDatastoreAdapter- Returns:
- the pattern string.
-
getPatternExpressionZeroMoreCharacters
The pattern string for representing zero or more characters that is expanded in word searches. Most of databases will use the percent sign character.- Specified by:
getPatternExpressionZeroMoreCharactersin interfaceDatastoreAdapter- Returns:
- the pattern string.
-
getEscapePatternExpression
The character for escaping characters in pattern expressions.- Specified by:
getEscapePatternExpressionin interfaceDatastoreAdapter- Returns:
- the character.
-
getEscapeCharacter
The character for escaping characters in pattern expressions.- Specified by:
getEscapeCharacterin interfaceDatastoreAdapter- Returns:
- the character.
-
getContinuationString
Continuation string to use where the SQL statement goes over more than 1 line. Some JDBC adapters (e.g DB2) don't do conversion.- Returns:
- Continuation string.
-
getNumericConversionFunction
Accessor for the function to use for converting to numeric.- Specified by:
getNumericConversionFunctionin interfaceDatastoreAdapter- Returns:
- The numeric conversion function for this datastore.
-
isStatementCancel
return whether this exception represents a cancelled statement.- Specified by:
isStatementCancelin interfaceDatastoreAdapter- Parameters:
sqle- the exception- Returns:
- whether it is a cancel
-
isStatementTimeout
return whether this exception represents a timed out statement.- Specified by:
isStatementTimeoutin interfaceDatastoreAdapter- Parameters:
sqle- the exception- Returns:
- whether it is a timeout
-
validToIndexMapping
Description copied from interface:DatastoreAdapterMethod to return whether the specified mapping is indexable. Allows a datastore to not index particular column types.- Specified by:
validToIndexMappingin interfaceDatastoreAdapter- Parameters:
mapping- The mapping- Returns:
- Whether it is indexable
-
getSQLOperationClass
Description copied from interface:DatastoreAdapterAccessor for the SQLOperation class for the specified operation (if available for this datastore).- Specified by:
getSQLOperationClassin interfaceDatastoreAdapter- Parameters:
operationName- operation name- Returns:
- SQLOperation class (or null if none available)
-
getSQLMethodClass
public Class<? extends SQLMethod> getSQLMethodClass(String className, String methodName, org.datanucleus.ClassLoaderResolver clr) Description copied from interface:DatastoreAdapterAccessor for the SQLMethod class for the query invocation of specified class + method name (if available for this datastore).- Specified by:
getSQLMethodClassin interfaceDatastoreAdapter- Parameters:
className- Name of the class (or null if this is a STATIC method)methodName- Method nameclr- ClassLoader resolver, in case className is a subclass of a supported type- Returns:
- The SQLMethod class (or null if not defined for this datastore).
-
loadColumnMappings
protected void loadColumnMappings(org.datanucleus.plugin.PluginManager pluginMgr, org.datanucleus.ClassLoaderResolver clr) Load all column mappings defined in the associated plugins via the plugin mechanism. All individual DatastoreAdapters should load up their own built-in support.- Parameters:
pluginMgr- the PluginManagerclr- the ClassLoaderResolver
-
registerColumnMapping
public void registerColumnMapping(String javaTypeName, Class<? extends ColumnMapping> columnMappingType, String jdbcType, String sqlType, boolean dflt) Description copied from interface:DatastoreAdapterMethod to register a column mapping for a specified java type, and against particular JDBC/SQL type.- Specified by:
registerColumnMappingin interfaceDatastoreAdapter- Parameters:
javaTypeName- Java type that this is used forcolumnMappingType- The column mapping class to usejdbcType- The JDBC typesqlType- The SQL type (optional)dflt- Whether this is the default mapping for this java type
-
registerColumnMapping
public void registerColumnMapping(String javaTypeName, Class<? extends ColumnMapping> columnMappingType, JDBCType jdbcType, String sqlType, boolean dflt) -
deregisterColumnMappingsForJDBCType
Utility to deregister all datastore mappings for a JDBC type. This is called when a JDBC driver doesn't own up to knowing about a JDBC type so we ensure that there are no DataNucleus-added references to that JDBC type.- Specified by:
deregisterColumnMappingsForJDBCTypein interfaceDatastoreAdapter- Parameters:
jdbcTypeName- The JDBC type name
-
getDefaultSqlTypeForJavaType
Description copied from interface:DatastoreAdapterMethod to return the default sql-type for the specified java type (and JDBC type)- Specified by:
getDefaultSqlTypeForJavaTypein interfaceDatastoreAdapter- Parameters:
javaType- The java typejdbcType- The JDBC type (optional)- Returns:
- The SQL type
-
getColumnMappingClass
public Class<? extends ColumnMapping> getColumnMappingClass(String javaType, String jdbcType, String sqlType, org.datanucleus.ClassLoaderResolver clr, String fieldName) Accessor for a datastore mapping class for the specified java type (and optional jdbc-type or sql-type).- Specified by:
getColumnMappingClassin interfaceDatastoreAdapter- Parameters:
javaType- The java typejdbcType- The JDBC typesqlType- The SQL Typeclr- ClassLoader resolver to usefieldName- Name of the field (if known, for logging only)- Returns:
- The datastore mapping class
-