Interface DatastoreAdapter
- All Known Implementing Classes:
BaseDatastoreAdapter
,CloudSpannerAdapter
,DB2Adapter
,DB2AS400Adapter
,DerbyAdapter
,FirebirdAdapter
,H2Adapter
,HSQLAdapter
,InformixAdapter
,MySQLAdapter
,NuoDBAdapter
,PointbaseAdapter
,PostgreSQLAdapter
,SAPDBAdapter
,SQLAnywhereAdapter
,SQLiteAdapter
,SQLServerAdapter
,SybaseAdapter
,TimesTenAdapter
,VirtuosoAdapter
public interface DatastoreAdapter
Definition of a datastore adapter, providing all characteristics of the underlying datastore
such as whether it supports FKs, indexes, and what statement syntax to use.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Whether this database supports joining outer and inner queries using columns.static final String
Whether this datastore supports ALTER TABLE DROP constraintsstatic final String
Whether this datastore supports ALTER TABLE DROP FOREIGN KEY constraintsstatic final String
Accessor for whether the RDBMS supports ANSI cross-join syntax.static final String
Accessor for whether the RDBMS supports ANSI join syntax.static final String
Whether "Types.BIT" is really mapped as BOOLEAN.static final String
Accessor for whether setting a BLOB value allows use of PreparedStatement.setString()static final String
Whether we support Boolean comparisons.static final String
Whether this datastore supports the use of the catalog name in ORM table definitions (DDL).static final String
Some databases store character strings in CHAR(XX) columns and when read back in have been padded with spaces.static final String
Whether this datastore supports the use of "CHECK" in CREATE TABLE statements (DDL).static final String
Whether this datastore supports the use of CHECK after the column definitions in the CREATE TABLE statements (DDL).static final String
Accessor for whether setting a CLOB value allows use of PreparedStatement.setString()static final String
Whether it supports specifying length "type" for a column, e.g VARCHAR(50 BYTE).static final String
Whether to support ASC|DESC on columns in an INDEX.static final String
Whether to create indexes before foreign keys.static final String
Accessor for whether the RDBMS supports cross-join as "INNER 1=1" syntax.static final String
Whether DATETIME stores milliseconds.static final String
Whether any DEFAULT tag will be before any NULL/NOT NULL in the column options.static final String
Whether we support DEFAULT tag in CREATE TABLE statementsstatic final String
Whether we support DEFAULT tag together with NOT NULL in CREATE TABLE statements.static final String
Whether this datastore supports deferred constraints.static final String
static final String
static final String
Whether the RDBMS supports use of EXISTS syntax.static final String
static final String
static final String
static final String
static final String
Whether this datastore supports the use of FOREIGN KEY after the column definitions in CREATE TABLE statements (DDL).static final String
static final String
static final String
static final String
static final String
Whether the datastore supports "Statement.getGeneratedKeys".static final String
Whether the GROUP BY has to include all primary expressions selected.static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Whether we support identity (auto-increment) keys with column type specification.static final String
Whether this datastore adapter supports identity (autoincrement) fields.static final String
Whether we support identity (auto-increment) keys with nullability specification.static final String
Whether this adapter requires any specification of primary key in the column definition of CREATE TABLE.static final String
Whether to include any ORDER BY columns in a SELECT.static final String
static final String
Whether the row lock is to be placed after the FROM.static final String
Whether the row lock is to be placed within the JOIN clause.static final String
Whether the row lock should use SELECT ...static final String
Whether the row lock, when using SELECT ...static final String
static final String
static final String
Some databases, Oracle, treats an empty string (0 length) equals null.static final String
Whether we support NULLs in candidate keys.static final String
Whether the database support NULLs in the column options for table creation.static final String
static final String
static final String
static final String
Whether we support ANSI "NULLS [FIRST|LAST]" directives in ORDER expressions.static final String
Whether we support ordering of NULLs using "(CASE WHEN [Order] IS NULL THEN 0 ELSE 1 END), [Order]"static final String
Whether we support ordering of NULLs using {col} IS NULL.static final String
Whether we support ordering of NULLs using ISNULL.static final String
In SAPDB any orderby has to be using the index(es) of any SELECT column(s) rather than their name(s).static final String
static final String
static final String
Whether the database server supports persist of an unassigned character ("0x0").static final String
Whether the datastore supports specification of the primary key in CREATE TABLE statements.static final String
Whether this datastore supports "SELECT a.* FROM (SELECT * FROM TBL1 INNER JOIN TBL2 ON tbl1.x = tbl2.y ) a" If the database does not support the SQL statement generated is like "SELECT a.* FROM (TBL1 INNER JOIN TBL2 ON tbl1.x = tbl2.y ) a"static final String
Cloud Spanner needs to use raw strings (r'') so that it can escape /_% characters by only one / character.static final String
static final String
static final String
static final String
Do we support right outer join?static final String
Whether this datastore supports the use of the schema name in ORM table definitions (DDL).static final String
Whether we support sequences.static final String
Do we support SOME|ALL|ANY {subquery}.static final String
Whether this datastore supports batching of statements.static final String
Whether this datastore supports stored procedures.static final String
Whether the adapter supports subqueries in the HAVING clause.static final String
static final String
static final String
static final String
static final String
static final String
Whether the RDBMS supports UNION syntax.static final String
Whether this datastore supports the use of UNIQUE after the column definitions in CREATE TABLE statements (DDL).static final String
static final String
static final String
Union combines the results of two or more queries into a single result set.static final String
Support for JDO compatible UUID-STRING value generation.static final String
Whether the RDBMS supports SQL VIEWs. -
Method Summary
Modifier and TypeMethodDescriptionvoid
deregisterColumnMappingsForJDBCType
(String jdbcTypeName) Method to remove all support for the specified JDBC type (since the JDBC driver doesn't know about it)long
getAdapterTime
(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 (string to separate the catalog/schema and the identifier).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) Method to return the column mapping class to use for the specified java type (and optional JDBC / SQL types).getColumns
(Connection conn, String catalog, String schema, String table, String columnNamePattern) Accessor for table and column information for a catalog/schema in this datastore.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 SQL to add an index to its table.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.int
getDatastoreIdentifierMaxLength
(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.int
Accessor for the driver major versionint
Accessor for the 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 tableAccessor for the quote string to use when quoting identifiers.Return the java type that represents any identity (autoincrement) column value.getIdentityKeyword
(org.datanucleus.store.StoreManager storeMgr) Accessor for the identity (auto-increment) keyword for generating DDLs (CREATE TABLEs...).default String
getIdentityKeyword
(org.datanucleus.store.StoreManager storeMgr, ColumnMapping columnMapping) Accessor for the identity (auto-increment) keyword for generating DDLs (CREATE TABLEs...).getIdentityLastValueStmt
(Table table, String columnName) Accessor for the identity (autoincrement) sql statement to get the latest key value for this table.Method to retutn the INSERT statement to use when inserting into a table that has no columns specified.int
getJDBCTypeForName
(String typeName) Method to return the type given the "jdbc-type" name.getMappingManager
(RDBMSStoreManager storeMgr) Accessor for a Mapping Manager suitable for use with this datastore adapter.int
Accessor for the maximum foreign keys by table permitted in this datastore.int
Accessor for the maximum indexes by table permitted in this datastore.getNameForJDBCType
(int jdbcType) Return a name for a JDBC Types value.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 rownumber 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).int
Accessor 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 sequenceName, Integer min, Integer max, Integer start, Integer increment, Integer cacheSize) Accessor for the sequence create statement for this datastore.getSequenceNextStmt
(String sequenceName) 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).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 nullint
Accessor for the transaction isolation level to use during schema creation.int
getUnlimitedLengthPrecisionValue
(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 basic SQL for an UPDATE TABLE statement.Accessor for the Vendor ID for this datastore.void
initialise
(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn) Initialise the datastore adapter.void
Creates the auxiliary functions/procedures in the datastorevoid
initialiseTypes
(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn) Initialise the types for this datastore.boolean
isIdentityFieldDataType
(String columnDef) Verifies if the givencolumnDef
is an identity (autoincrement) field type for the datastore.boolean
isReservedKeyword
(String word) Method to check if a word is reserved for this datastore.boolean
return whether this exception represents a cancelled statement.boolean
return whether this exception represents a timed out statement.boolean
isValidPrimaryKeyType
(org.datanucleus.metadata.JdbcType datatype) Method to return whether the specified JDBC type is valid for use in a PrimaryKey.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.void
registerColumnMapping
(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.boolean
sequenceExists
(Connection conn, String catalogName, String schemaName, String seqName) Convenience method to return whether the specified sequence already exists.boolean
supportsOption
(String option) Accessor for whether the supplied option is supported.boolean
supportsQueryFetchSize
(int size) Whether the datastore will support setting the query fetch size to the supplied value.boolean
supportsTransactionIsolation
(int level) Accessor for whether this database adapter supports the specified transaction isolation.toString()
Method to return this object as a string.boolean
validToIndexMapping
(JavaTypeMapping mapping) Method to return whether the specified mapping is indexable.boolean
Method to return if it is valid to select the specified mapping for the specified statement for this datastore adapter.
-
Field Details
-
IDENTITY_COLUMNS
Whether this datastore adapter supports identity (autoincrement) fields. In SQL this would be things like "AUTOINCREMENT", "IDENTITY", "SERIAL".- See Also:
-
IDENTITY_KEYS_NULL_SPECIFICATION
Whether we support identity (auto-increment) keys with nullability specification.- See Also:
-
IDENTITY_COLUMN_TYPE_SPECIFICATION
Whether we support identity (auto-increment) keys with column type specification.- See Also:
-
IDENTITY_PK_IN_CREATE_TABLE_COLUMN_DEF
Whether this adapter requires any specification of primary key in the column definition of CREATE TABLE.- See Also:
-
SEQUENCES
Whether we support sequences.- See Also:
-
VALUE_GENERATION_UUID_STRING
Support for JDO compatible UUID-STRING value generation.- See Also:
-
BIT_IS_REALLY_BOOLEAN
Whether "Types.BIT" is really mapped as BOOLEAN.- See Also:
-
RIGHT_OUTER_JOIN
Do we support right outer join?- See Also:
-
SOME_ANY_ALL_SUBQUERY_EXPRESSIONS
Do we support SOME|ALL|ANY {subquery}.- See Also:
-
BOOLEAN_COMPARISON
Whether we support Boolean comparisons.- See Also:
-
ESCAPE_EXPRESSION_IN_LIKE_PREDICATE
- See Also:
-
PROJECTION_IN_TABLE_REFERENCE_JOINS
Whether this datastore supports "SELECT a.* FROM (SELECT * FROM TBL1 INNER JOIN TBL2 ON tbl1.x = tbl2.y ) a" If the database does not support the SQL statement generated is like "SELECT a.* FROM (TBL1 INNER JOIN TBL2 ON tbl1.x = tbl2.y ) a"- See Also:
-
CATALOGS_IN_TABLE_DEFINITIONS
Whether this datastore supports the use of the catalog name in ORM table definitions (DDL).- See Also:
-
SCHEMAS_IN_TABLE_DEFINITIONS
Whether this datastore supports the use of the schema name in ORM table definitions (DDL).- See Also:
-
IDENTIFIERS_LOWERCASE
- See Also:
-
IDENTIFIERS_MIXEDCASE
- See Also:
-
IDENTIFIERS_UPPERCASE
- See Also:
-
IDENTIFIERS_LOWERCASE_QUOTED
- See Also:
-
IDENTIFIERS_MIXEDCASE_QUOTED
- See Also:
-
IDENTIFIERS_UPPERCASE_QUOTED
- See Also:
-
IDENTIFIERS_MIXEDCASE_SENSITIVE
- See Also:
-
IDENTIFIERS_MIXEDCASE_QUOTED_SENSITIVE
- See Also:
-
VIEWS
Whether the RDBMS supports SQL VIEWs.- See Also:
-
UNION_SYNTAX
Whether the RDBMS supports UNION syntax.- See Also:
-
USE_UNION_ALL
Union combines the results of two or more queries into a single result set. Union include only distinct rows and Union all may include duplicates. When using the UNION statement, keep in mind that, by default, it performs the equivalent of a SELECT DISTINCT on the final result set. In other words, UNION takes the results of two like recordsets, combines them, and then performs a SELECT DISTINCT in order to eliminate any duplicate rows. This process occurs even if there are no duplicate records in the final recordset. If you know that there are duplicate records, and this presents a problem for your application, then by all means use the UNION statement to eliminate the duplicate rows. On the other hand, if you know that there will never be any duplicate rows, or if there are, and this presents no problem to your application, then you should use the UNION ALL statement instead of the UNION statement. The advantage of the UNION ALL is that is does not perform the SELECT DISTINCT function, which saves a lot of unnecessary SQL Server resources from being using.- See Also:
-
EXISTS_SYNTAX
Whether the RDBMS supports use of EXISTS syntax.- See Also:
-
ALTER_TABLE_DROP_CONSTRAINT_SYNTAX
Whether this datastore supports ALTER TABLE DROP constraints- See Also:
-
ALTER_TABLE_DROP_FOREIGN_KEY_CONSTRAINT
Whether this datastore supports ALTER TABLE DROP FOREIGN KEY constraints- See Also:
-
DEFERRED_CONSTRAINTS
Whether this datastore supports deferred constraints.- See Also:
-
DISTINCT_WITH_SELECT_FOR_UPDATE
- See Also:
-
GROUPING_WITH_SELECT_FOR_UPDATE
- See Also:
-
HAVING_WITH_SELECT_FOR_UPDATE
- See Also:
-
ORDERING_WITH_SELECT_FOR_UPDATE
- See Also:
-
MULTITABLES_WITH_SELECT_FOR_UPDATE
- See Also:
-
UPDATE_STATEMENT_ALLOW_TABLE_ALIAS_IN_SET_CLAUSE
- See Also:
-
UPDATE_DELETE_STATEMENT_ALLOW_TABLE_ALIAS_IN_WHERE_CLAUSE
- See Also:
-
GROUP_BY_REQUIRES_ALL_SELECT_PRIMARIES
Whether the GROUP BY has to include all primary expressions selected.- See Also:
-
PERSIST_OF_UNASSIGNED_CHAR
Whether the database server supports persist of an unassigned character ("0x0"). If not, any unassigned character will be replaced by " " (space) on persist.- See Also:
-
CHAR_COLUMNS_PADDED_WITH_SPACES
Some databases store character strings in CHAR(XX) columns and when read back in have been padded with spaces.- See Also:
-
NULL_EQUALS_EMPTY_STRING
Some databases, Oracle, treats an empty string (0 length) equals null.- See Also:
-
STATEMENT_BATCHING
Whether this datastore supports batching of statements.- See Also:
-
CHECK_IN_CREATE_STATEMENTS
Whether this datastore supports the use of "CHECK" in CREATE TABLE statements (DDL).- See Also:
-
CHECK_IN_END_CREATE_STATEMENTS
Whether this datastore supports the use of CHECK after the column definitions in the CREATE TABLE statements (DDL). for exampleCREATE TABLE MYTABLE ( COL_A int, COL_B char(1), PRIMARY KEY (COL_A), CHECK (COL_B IN ('Y','N')) )
- See Also:
-
UNIQUE_IN_END_CREATE_STATEMENTS
Whether this datastore supports the use of UNIQUE after the column definitions in CREATE TABLE statements (DDL). For exampleCREATE TABLE MYTABLE ( COL_A int, COL_B char(1), PRIMARY KEY (COL_A), UNIQUE (COL_B ...) )
- See Also:
-
FK_IN_END_CREATE_STATEMENTS
Whether this datastore supports the use of FOREIGN KEY after the column definitions in CREATE TABLE statements (DDL). For exampleCREATE TABLE MYTABLE ( COL_A int, COL_B char(1), FOREIGN KEY (COL_A) REFERENCES TBL2(COL_X) )
- See Also:
-
PRIMARYKEY_IN_CREATE_STATEMENTS
Whether the datastore supports specification of the primary key in CREATE TABLE statements.- See Also:
-
GET_GENERATED_KEYS_STATEMENT
Whether the datastore supports "Statement.getGeneratedKeys".- See Also:
-
NULLS_IN_CANDIDATE_KEYS
Whether we support NULLs in candidate keys.- See Also:
-
NULLS_KEYWORD_IN_COLUMN_OPTIONS
Whether the database support NULLs in the column options for table creation.- See Also:
-
DEFAULT_KEYWORD_IN_COLUMN_OPTIONS
Whether we support DEFAULT tag in CREATE TABLE statements- See Also:
-
DEFAULT_KEYWORD_WITH_NOT_NULL_IN_COLUMN_OPTIONS
Whether we support DEFAULT tag together with NOT NULL in CREATE TABLE statements.CREATE TABLE X ( MEMORY_SIZE BIGINT DEFAULT 0 NOT NULL )
Some databases only support DEFAULT {ConstantExpression | NULL}- See Also:
-
DEFAULT_BEFORE_NULL_IN_COLUMN_OPTIONS
Whether any DEFAULT tag will be before any NULL/NOT NULL in the column options.- See Also:
-
ANSI_JOIN_SYNTAX
Accessor for whether the RDBMS supports ANSI join syntax.- See Also:
-
ANSI_CROSSJOIN_SYNTAX
Accessor for whether the RDBMS supports ANSI cross-join syntax.- See Also:
-
CROSSJOIN_ASINNER11_SYNTAX
Accessor for whether the RDBMS supports cross-join as "INNER 1=1" syntax.- See Also:
-
LOCK_ROW_USING_SELECT_FOR_UPDATE
Whether the row lock should use SELECT ... FOR UPDATE.- See Also:
-
LOCK_ROW_USING_SELECT_FOR_UPDATE_NOWAIT
Whether the row lock, when using SELECT ... FOR UPDATE, should also append NOWAIT.- See Also:
-
LOCK_ROW_USING_OPTION_AFTER_FROM
Whether the row lock is to be placed after the FROM.- See Also:
-
LOCK_ROW_USING_OPTION_WITHIN_JOIN
Whether the row lock is to be placed within the JOIN clause.- See Also:
-
BLOB_SET_USING_SETSTRING
Accessor for whether setting a BLOB value allows use of PreparedStatement.setString()- See Also:
-
CLOB_SET_USING_SETSTRING
Accessor for whether setting a CLOB value allows use of PreparedStatement.setString()- See Also:
-
CREATE_INDEXES_BEFORE_FOREIGN_KEYS
Whether to create indexes before foreign keys.- See Also:
-
CREATE_INDEX_COLUMN_ORDERING
Whether to support ASC|DESC on columns in an INDEX.- See Also:
-
INCLUDE_ORDERBY_COLS_IN_SELECT
Whether to include any ORDER BY columns in a SELECT.- See Also:
-
DATETIME_STORES_MILLISECS
Whether DATETIME stores milliseconds.- See Also:
-
ACCESS_PARENTQUERY_IN_SUBQUERY_JOINED
Whether this database supports joining outer and inner queries using columns. i.e can you refer to a column of the outer query in a subquery when the outer query table is not the primary table of the outer query (i.e joined)- See Also:
-
SUBQUERY_IN_HAVING
Whether the adapter supports subqueries in the HAVING clause.- See Also:
-
ORDERBY_USING_SELECT_COLUMN_INDEX
In SAPDB any orderby has to be using the index(es) of any SELECT column(s) rather than their name(s).- See Also:
-
ORDERBY_NULLS_DIRECTIVES
Whether we support ANSI "NULLS [FIRST|LAST]" directives in ORDER expressions.- See Also:
-
ORDERBY_NULLS_USING_ISNULL
Whether we support ordering of NULLs using ISNULL.- See Also:
-
ORDERBY_NULLS_USING_COLUMN_IS_NULL
Whether we support ordering of NULLs using {col} IS NULL.- See Also:
-
ORDERBY_NULLS_USING_CASE_NULL
Whether we support ordering of NULLs using "(CASE WHEN [Order] IS NULL THEN 0 ELSE 1 END), [Order]"- See Also:
-
STORED_PROCEDURES
Whether this datastore supports stored procedures.- See Also:
-
FK_UPDATE_ACTION_CASCADE
- See Also:
-
FK_UPDATE_ACTION_DEFAULT
- See Also:
-
FK_UPDATE_ACTION_NULL
- See Also:
-
FK_UPDATE_ACTION_RESTRICT
- See Also:
-
FK_DELETE_ACTION_CASCADE
- See Also:
-
FK_DELETE_ACTION_DEFAULT
- See Also:
-
FK_DELETE_ACTION_NULL
- See Also:
-
FK_DELETE_ACTION_RESTRICT
- See Also:
-
TX_ISOLATION_NONE
- See Also:
-
TX_ISOLATION_READ_COMMITTED
- See Also:
-
TX_ISOLATION_READ_UNCOMMITTED
- See Also:
-
TX_ISOLATION_REPEATABLE_READ
- See Also:
-
TX_ISOLATION_SERIALIZABLE
- See Also:
-
RESULTSET_TYPE_FORWARD_ONLY
- See Also:
-
RESULTSET_TYPE_SCROLL_SENSITIVE
- See Also:
-
RESULTSET_TYPE_SCROLL_INSENSITIVE
- See Also:
-
HOLD_CURSORS_OVER_COMMIT
- See Also:
-
OPERATOR_BITWISE_AND
- See Also:
-
OPERATOR_BITWISE_OR
- See Also:
-
OPERATOR_BITWISE_XOR
- See Also:
-
NATIVE_ENUM_TYPE
- See Also:
-
PARAMETER_IN_CASE_IN_UPDATE_CLAUSE
- See Also:
-
COLUMN_LENGTH_SEMANTICS
Whether it supports specifying length "type" for a column, e.g VARCHAR(50 BYTE).- See Also:
-
RAW_PREFIX_LIKE_STATEMENTS
Cloud Spanner needs to use raw strings (r'') so that it can escape /_% characters by only one / character. Otherwise, double // is required. StringMatches method uses this functionality.- See Also:
-
INCLUDE_TABLE_INDEX_STATISTICS
- See Also:
-
-
Method Details
-
initialise
void initialise(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn) Initialise the datastore adapter.- Parameters:
handler
- SchemaHandler that we initialise the types formconn
- Managed connection to use
-
initialiseTypes
void initialiseTypes(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn) Initialise the types for this datastore.- Parameters:
handler
- SchemaHandler that we initialise the types formconn
- Managed connection to use
-
getSupportedOptions
Collection<String> getSupportedOptions()Accessor for the options that are supported by this datastore adapter and the underlying datastore.- Returns:
- The options (Collection<String>)
-
supportsOption
Accessor for whether the supplied option is supported.- Parameters:
option
- The option- Returns:
- Whether supported.
-
getPreferredDefaultSQLTypeForJDBCType
Way for a DatastoreAdapter to specify a preferred default SQL type for a JDBC type (when there are multiple).- Parameters:
jdbcType
- The JDBC type- Returns:
- The SQL type preferred
-
getNameForJDBCType
Return a name for a JDBC Types value.- Parameters:
jdbcType
- The jdbc type- Returns:
- The name
-
getJDBCTypeForName
Method to return the type given the "jdbc-type" name.- Parameters:
typeName
- "jdbc-type" name- Returns:
- Whether it is valid
-
getMappingManager
Accessor for a Mapping Manager suitable for use with this datastore adapter.- Parameters:
storeMgr
- The StoreManager- Returns:
- The Mapping Manager.
-
getVendorID
String getVendorID()Accessor for the Vendor ID for this datastore.- Returns:
- Vendor id for this datastore
-
isReservedKeyword
Method to check if a word is reserved for this datastore.- Parameters:
word
- The word- Returns:
- Whether it is reserved
-
initialiseDatastore
Creates the auxiliary functions/procedures in the datastore- Parameters:
conn
- the connection to the datastore
-
getIdentifierQuoteString
String getIdentifierQuoteString()Accessor for the quote string to use when quoting identifiers.- Returns:
- The quote string for the identifier
-
getCatalogSeparator
String getCatalogSeparator()Accessor for the catalog separator (string to separate the catalog/schema and the identifier).- Returns:
- Catalog separator string.
-
getAdapterTime
Utility to return the adapter time in case there are rounding issues with millisecs etc.- Parameters:
time
- The timestamp- Returns:
- The time in millisecs
-
getDatastoreProductName
String getDatastoreProductName()Accessor for the datastore product name.- Returns:
- product name
-
getDatastoreProductVersion
String getDatastoreProductVersion()Accessor for the datastore product version.- Returns:
- product version
-
getDatastoreDriverName
String getDatastoreDriverName()Accessor for the datastore driver name.- Returns:
- product name
-
getDatastoreDriverVersion
String getDatastoreDriverVersion()Accessor for the datastore driver version.- Returns:
- driver version
-
getDriverMajorVersion
int getDriverMajorVersion()Accessor for the driver major version- Returns:
- The driver major version
-
getDriverMinorVersion
int getDriverMinorVersion()Accessor for the driver minor version- Returns:
- The driver minor version
-
isIdentityFieldDataType
Verifies if the givencolumnDef
is an identity (autoincrement) field type for the datastore.- Parameters:
columnDef
- the datastore type name- Returns:
- true when the
columnDef
has values for identity generation in the datastore
-
getIdentityJavaTypeForType
Return the java type that represents any identity (autoincrement) column value.- Parameters:
type
- The type of the member mapping to an IDENTITY column- Returns:
- The type that should be used in generating the column
-
getIdentityLastValueStmt
Accessor for the identity (autoincrement) sql statement to get the latest key value for this table.- Parameters:
table
- Table (that the autoincrement is for)columnName
- (that the autoincrement is for)- Returns:
- The statement for getting the latest auto-increment/identity key
-
getIdentityKeyword
Accessor for the identity (auto-increment) keyword for generating DDLs (CREATE TABLEs...).- Parameters:
storeMgr
- The Store manager- Returns:
- The keyword for a column using auto-increment/identity
-
getIdentityKeyword
default String getIdentityKeyword(org.datanucleus.store.StoreManager storeMgr, ColumnMapping columnMapping) Accessor for the identity (auto-increment) keyword for generating DDLs (CREATE TABLEs...). Provides theColumnMapping
as context for data stores that have different identity keywords based on the mapped Java / JDBC type. Defaults togetIdentityKeyword(StoreManager)
for backward-compatibility.- Parameters:
storeMgr
- The Store managercolumnMapping
- The column mapping- Returns:
- The keyword for a column using auto-increment/identity
-
getDatastoreIdentifierMaxLength
Method to return the maximum length of a datastore identifier of the specified type. If no limit exists then returns -1- Parameters:
identifierType
- Type of identifier- Returns:
- The max permitted length of this type of identifier
-
getMaxForeignKeys
int getMaxForeignKeys()Accessor for the maximum foreign keys by table permitted in this datastore.- Returns:
- Max number of foreign keys
-
getMaxIndexes
int getMaxIndexes()Accessor for the maximum indexes by table permitted in this datastore.- Returns:
- Max number of indices
-
supportsQueryFetchSize
boolean supportsQueryFetchSize(int size) Whether the datastore will support setting the query fetch size to the supplied value.- Parameters:
size
- The value to set to- Returns:
- Whether it is supported.
-
toString
String toString()Method to return this object as a string. -
supportsTransactionIsolation
boolean supportsTransactionIsolation(int level) Accessor for whether this database adapter supports the specified transaction isolation.- Parameters:
level
- The isolation level (as defined by Connection enums).- Returns:
- Whether it is supported.
-
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}- 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
String getRangeByRowNumberColumn()Method to return the column name to use when handling ranges via a rownumber on the select using the original method (DB2). Defaults to an empty string (not supported).- Returns:
- The row number column.
-
getRangeByRowNumberColumn2
String 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).- Returns:
- The row number column.
-
getColumns
ResultSet getColumns(Connection conn, String catalog, String schema, String table, String columnNamePattern) throws SQLException Accessor for table and column information for a catalog/schema in this datastore.- Parameters:
conn
- Connection to usecatalog
- The catalog (null if none)schema
- The schema (null if none)table
- The table (null if all)columnNamePattern
- The column name (null if all)- Returns:
- ResultSet containing the table/column information
- Throws:
SQLException
- Thrown if an error occurs
-
getInsertStatementForNoColumns
Method to retutn 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).- Parameters:
table
- The table- Returns:
- The statement for the INSERT
-
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 the database metadata. However, for some types in some databases the value must be computed.- 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.
-
getCreateDatabaseStatement
Method to return the statement necessary to create a database with this RDBMS. Note that some RDBMS don't support this.- Parameters:
catalogName
- name of the catalogschemaName
- Name of the schema- Returns:
- The DDL statement
-
getDropDatabaseStatement
Method to return the statement necessary to drop a database with this RDBMS. Note that some RDBMS don't support this.- 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
- Parameters:
table
- The table to drop.- Returns:
- The text of the SQL statement.
-
getDeleteTableStatement
Method to return the basic SQL for a DELETE TABLE statement. Returns a String likeDELETE FROM tbl t1
. Doesn't include any where clause.- Parameters:
tbl
- The SQLTable to delete- Returns:
- The delete table string
-
getUpdateTableStatement
Method to return the basic SQL for an UPDATE TABLE statement. Returns a String likeUPDATE tbl t1 SET x1 = val1
. Doesn't include any WHERE clause.- Parameters:
tbl
- The SQLTable to updatesetSQL
- The SQLText for the SET component- Returns:
- The update table string
-
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)
- Parameters:
ck
- An object describing the candidate key.factory
- Identifier factory- Returns:
- The text of the SQL statement.
-
isValidPrimaryKeyType
boolean isValidPrimaryKeyType(org.datanucleus.metadata.JdbcType datatype) Method to return whether the specified JDBC type is valid for use in a PrimaryKey.- Parameters:
datatype
- The JDBC type.- Returns:
- Whether it is valid for use in the PK
-
getAddColumnStatement
Accessor for the SQL statement to add a column to a table.- Parameters:
table
- The tablecol
- The column- Returns:
- The SQL necessary to add the column
-
getCreateIndexStatement
Returns the appropriate SQL to add an index to its table. It should return something like:CREATE INDEX FOO_N1 ON FOO (BAR,BAZ) CREATE UNIQUE INDEX FOO_U1 ON FOO (BAR,BAZ)
- Parameters:
idx
- An object describing the index.factory
- Identifier factory- Returns:
- The text of the SQL statement.
-
getExistingIndexes
ResultSet getExistingIndexes(Connection conn, String catalog, String schema, String table) throws SQLException Provide the existing indexes in the database for the table- 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
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)
- Parameters:
table
- The table to create.columns
- The columns of the table.props
- Properties for controlling the table creationfactory
- Identifier factory- 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)
- Parameters:
pk
- An object describing the primary 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)
- Parameters:
fk
- An object describing the foreign key.factory
- Identifier factory- 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
- Parameters:
view
- The view to drop.- Returns:
- The text of the SQL statement.
-
getSelectForUpdateText
String 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).- Returns:
- The "FOR UPDATE" text
-
getSurrogateForEmptyStrings
String getSurrogateForEmptyStrings()Some databases, Oracle, treats an empty string (0 length) equals null- Returns:
- returns a surrogate to replace the empty string in the database otherwise it would be treated as null
-
getTransactionIsolationForSchemaCreation
int getTransactionIsolationForSchemaCreation()Accessor for the transaction isolation level to use during schema creation.- Returns:
- The transaction isolation level for schema generation process
-
getRequiredTransactionIsolationLevel
int getRequiredTransactionIsolationLevel()Accessor for the "required" transaction isolation level if it has to be a certain value for this adapter.- Returns:
- Transaction isolation level (-1 implies no restriction)
-
getCatalogName
Accessor for the Catalog Name for this datastore.- 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.- Parameters:
conn
- Connection to the datastore- Returns:
- The schema name
- Throws:
SQLException
- Thrown if error occurs in determining the schema name.
-
getSelectWithLockOption
String getSelectWithLockOption()The option to specify in "SELECT ... FROM TABLE ... WITH (option)" to lock instances Null if not supported.- Returns:
- The option to specify with "SELECT ... FROM TABLE ... WITH (option)"
-
getSelectNewUUIDStmt
String getSelectNewUUIDStmt()The function to creates a unique value of type uniqueidentifier.- Returns:
- The function. e.g. "SELECT NEWID()"
-
getSequenceNextStmt
Accessor for the sequence statement to get the next id for this datastore.- Parameters:
sequenceName
- Name of the sequence- Returns:
- The statement for getting the next id for the sequence
-
getSequenceCreateStmt
String getSequenceCreateStmt(String sequenceName, Integer min, Integer max, Integer start, Integer increment, Integer cacheSize) Accessor for the sequence create statement for this datastore.- Parameters:
sequenceName
- Name of the sequencemin
- Minimum value for the sequencemax
- Maximum value for the sequencestart
- Start value for the sequenceincrement
- Increment value for the sequencecacheSize
- Cache size for the sequence- Returns:
- The statement for getting the next id from the sequence
-
sequenceExists
Convenience method to return whether the specified sequence already exists.- Parameters:
conn
- Connection to use for checkingcatalogName
- Catalog nameschemaName
- Schema nameseqName
- Name of the sequence- Returns:
- Whether it exists
-
getReservedWords
Accessor for the reserved words constructed from the method DataBaseMetaData.getSQLKeywords + standard SQL reserved words- Returns:
- Set of reserved words
-
getDatastoreDateStatement
String getDatastoreDateStatement()Accessor for a statement that will return the statement to use to get the datastore date.- Returns:
- SQL statement to get the datastore date
-
getCheckConstraintForValues
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)
- Parameters:
identifier
- Column identifiervalues
- valid valuesnullable
- whether the datastore identifier is null- Returns:
- The check constraint
-
newSQLTypeInfo
Create 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.- Parameters:
rs
- ResultSet- Returns:
- The SQL type info
-
newRDBMSColumnInfo
Create 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.- Parameters:
rs
- Result Set- Returns:
- The column 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().- Parameters:
rs
- The result set returned from DatabaseMetaData.get??portedKeys()- Returns:
- The foreign key info
-
getOrderString
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.- 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.- Parameters:
stmt
- The statementm
- The mapping that we want to select- Returns:
- Whether it is valid
-
isStatementCancel
return whether this exception represents a cancelled statement.- Parameters:
sqle
- the exception- Returns:
- whether it is a cancel
-
isStatementTimeout
return whether this exception represents a timed out statement.- Parameters:
sqle
- the exception- Returns:
- whether it is a timeout
-
getNumericConversionFunction
String getNumericConversionFunction()Accessor for the function to use for converting to numeric.- Returns:
- The numeric conversion function for this datastore.
-
getEscapePatternExpression
String getEscapePatternExpression()The character for escaping characters in pattern expressions.- Returns:
- the character.
-
getEscapeCharacter
String getEscapeCharacter()The character for escaping characters in pattern expressions.- Returns:
- the character.
-
getPatternExpressionAnyCharacter
String getPatternExpressionAnyCharacter()The pattern string for representing one character that is expanded in word searches. Most of databases will use the underscore character.- Returns:
- the pattern string.
-
getPatternExpressionZeroMoreCharacters
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.- Returns:
- the pattern string.
-
validToIndexMapping
Method to return whether the specified mapping is indexable. Allows a datastore to not index particular column types.- Parameters:
mapping
- The mapping- Returns:
- Whether it is indexable
-
getSQLOperationClass
Accessor for the SQLOperation class for the specified operation (if available for this datastore).- Parameters:
operationName
- operation name- Returns:
- SQLOperation class (or null if none available)
-
getSQLMethodClass
Class<? extends SQLMethod> 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).- 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).
-
registerColumnMapping
void registerColumnMapping(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.- 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
-
deregisterColumnMappingsForJDBCType
Method to remove all support for the specified JDBC type (since the JDBC driver doesn't know about it)- Parameters:
jdbcTypeName
- The JDBC type
-
getDefaultSqlTypeForJavaType
Method to return the default sql-type for the specified java type (and JDBC type)- Parameters:
javaType
- The java typejdbcType
- The JDBC type (optional)- Returns:
- The SQL type
-
getColumnMappingClass
Class<? extends ColumnMapping> getColumnMappingClass(String javaType, String jdbcType, String sqlType, org.datanucleus.ClassLoaderResolver clr, String fieldName) Method to return the column mapping class to use for the specified java type (and optional JDBC / SQL types).- Parameters:
javaType
- The java type of the memberjdbcType
- The JDBC type (optional). If provided is used in preference to the java typesqlType
- The SQL type (optional). If provided is used in preference to JDBC typeclr
- ClassLoader resolverfieldName
- Name of the field/property (for logging only, can be null).- Returns:
- The column mapping type to use
-