public class BaseDatastoreAdapter extends Object implements DatastoreAdapter
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.
DatastoreAdapterFactory
,
DatabaseMetaData
Modifier and Type | Field and Description |
---|---|
protected String |
catalogSeparator
The String used to separate catalog and table name.
|
protected int |
datastoreMajorVersion
The major version number of the underlying datastore.
|
protected int |
datastoreMinorVersion
The minor version number of the underlying datastore.
|
protected String |
datastoreProductName
The product name of the underlying datastore.
|
protected String |
datastoreProductVersion
The version number of the underlying datastore as a string.
|
protected int |
datastoreRevisionVersion
The revision version number of the underlying datastore.
|
protected int |
driverMajorVersion
The major version number of the underlying driver.
|
protected int |
driverMinorVersion
The minor version number of the underlying driver.
|
protected String |
driverName
the JDBC driver name
|
protected String |
driverVersion
the JDBC driver version
|
protected String |
identifierQuoteString
The String used to quote identifiers.
|
protected int |
maxColumnNameLength
The maximum length to be used for a column name.
|
protected int |
maxConstraintNameLength
The maximum length to be used for a table constraint name.
|
protected int |
maxIndexNameLength
The maximum length to be used for an index name.
|
protected int |
maxTableNameLength
The maximum length to be used for a table name.
|
protected Map<String,Object> |
properties
Optional properties controlling the configuration.
|
protected HashSet<String> |
reservedKeywords
The set of reserved keywords for this datastore.
|
protected Map<Integer,String> |
supportedJdbcTypesById |
protected Collection<String> |
supportedOptions
Supported option names.
|
protected Map<Integer,String> |
unsupportedJdbcTypesById |
ACCESS_PARENTQUERY_IN_SUBQUERY_JOINED, ALLOW_TABLE_ALIAS_IN_UPDATE_SET_CLAUSE, ALTER_TABLE_DROP_CONSTRAINT_SYNTAX, ALTER_TABLE_DROP_FOREIGN_KEY_CONSTRAINT, ANALYSIS_METHODS, ANSI_CROSSJOIN_SYNTAX, ANSI_JOIN_SYNTAX, AUTO_INCREMENT_COLUMN_TYPE_SPECIFICATION, AUTO_INCREMENT_KEYS_NULL_SPECIFICATION, AUTO_INCREMENT_PK_IN_CREATE_TABLE_COLUMN_DEF, 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, 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, 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_COLUMNS, INCLUDE_ORDERBY_COLS_IN_SELECT, LOCK_OPTION_PLACED_AFTER_FROM, LOCK_OPTION_PLACED_WITHIN_JOIN, LOCK_WITH_SELECT_FOR_UPDATE, NULL_EQUALS_EMPTY_STRING, NULLS_IN_CANDIDATE_KEYS, NULLS_KEYWORD_IN_COLUMN_OPTIONS, ORDERBY_NULLS_DIRECTIVES, ORDERBY_USING_SELECT_COLUMN_INDEX, PERSIST_OF_UNASSIGNED_CHAR, PRIMARYKEY_IN_CREATE_STATEMENTS, PROJECTION_IN_TABLE_REFERENCE_JOINS, RESULTSET_TYPE_FORWARD_ONLY, RESULTSET_TYPE_SCROLL_INSENSITIVE, RESULTSET_TYPE_SCROLL_SENSITIVE, SCHEMAS_IN_TABLE_DEFINITIONS, SEQUENCES, STATEMENT_BATCHING, STORED_PROCEDURES, 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, USE_UNION_ALL, VIEWS
Modifier | Constructor and Description |
---|---|
protected |
BaseDatastoreAdapter(DatabaseMetaData metadata)
Constructs a database adapter based on the given JDBC metadata.
|
Modifier and Type | Method and Description |
---|---|
protected void |
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.
|
long |
getAdapterTime(Timestamp time)
Utility to return the adapter time in case there are rounding issues with millisecs etc.
|
String |
getAddCandidateKeyStatement(CandidateKey ck,
IdentifierFactory factory)
Returns the appropriate SQL to add a candidate key to its table.
|
String |
getAddColumnStatement(Table table,
Column col)
Accessor for the SQL statement to add a column to a table.
|
String |
getAddForeignKeyStatement(ForeignKey fk,
IdentifierFactory factory)
Returns the appropriate SQL to add a foreign key to its table.
|
String |
getAddPrimaryKeyStatement(PrimaryKey pk,
IdentifierFactory factory)
Returns the appropriate SQL to add a primary key to its table.
|
Class |
getAutoIncrementJavaTypeForType(Class type)
Return the java type that represents any autoincrement/identity column value.
|
String |
getAutoIncrementKeyword()
Accessor for the autoincrementing keyword for generating DDLs.
|
String |
getAutoIncrementStmt(Table table,
String columnName)
Accessor for the autoincrementing sql statement for this datastore.
|
String |
getCatalogName(Connection conn)
Accessor for the Catalog Name for this datastore.
|
String |
getCatalogSeparator()
Accessor for the catalog separator.
|
String |
getCheckConstraintForValues(DatastoreIdentifier identifier,
Object[] values,
boolean nullable)
Creates a CHECK constraint definition based on the given values
e.g.
|
ResultSet |
getColumns(Connection conn,
String catalog,
String schema,
String table,
String columnNamePattern)
Accessor for table and column information for a catalog/schema in this datastore.
|
String |
getContinuationString()
Continuation string to use where the SQL statement goes over more than 1
line.
|
String |
getCreateDatabaseStatement(String catalogName,
String schemaName)
Method to return the statement necessary to create a database with this RDBMS.
|
String |
getCreateIndexStatement(Index idx,
IdentifierFactory factory)
Returns the appropriate DDL to create an index.
|
String |
getCreateTableStatement(TableImpl table,
Column[] columns,
Properties props,
IdentifierFactory factory)
Returns the appropriate SQL to create the given table having the given
columns.
|
String |
getDatastoreDateStatement()
Accessor for a statement that will return the statement to use to get the datastore date.
|
String |
getDatastoreDriverName()
Accessor for the datastore driver name.
|
String |
getDatastoreDriverVersion()
Accessor for the datastore driver version.
|
int |
getDatastoreIdentifierMaxLength(IdentifierType identifierType)
Method to return the maximum length of a datastore identifier of the specified type.
|
String |
getDatastoreProductName()
Accessor for the datastore product name.
|
String |
getDatastoreProductVersion()
Accessor for the datastore product version.
|
String |
getDeleteTableStatement(SQLTable tbl)
Method to return the basic SQL for a DELETE TABLE statement.
|
int |
getDriverMajorVersion()
Accessor for the JDBC driver major version
|
int |
getDriverMinorVersion()
Accessor for the JDBC driver minor version
|
String |
getDropDatabaseStatement(String catalogName,
String schemaName)
Method to return the statement necessary to drop a database with this RDBMS.
|
String |
getDropTableStatement(Table table)
Returns the appropriate SQL to drop the given table.
|
String |
getDropViewStatement(ViewImpl view)
Returns the appropriate SQL to drop the given view.
|
String |
getEscapeCharacter()
The character for escaping characters in pattern expressions.
|
String |
getEscapePatternExpression()
The character for escaping characters in pattern expressions.
|
ResultSet |
getExistingIndexes(Connection conn,
String catalog,
String schema,
String table)
Provide the existing indexes in the database for the table.
|
String |
getIdentifierQuoteString()
Accessor for an identifier quote string.
|
String |
getInsertStatementForNoColumns(Table table)
Method to return 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.
|
MappingManager |
getMappingManager(RDBMSStoreManager storeMgr)
Accessor for a MappingManager suitable for use with this datastore adapter.
|
int |
getMaxForeignKeys()
Accessor for the maximum foreign keys by table permitted for this datastore.
|
int |
getMaxIndexes()
Accessor for the maximum indexes by schema permitted for this datastore.
|
protected int |
getMiliseconds(long nanos) |
String |
getNameForJDBCType(int jdbcType)
Return a name for a JDBC Types value.
|
String |
getNewUUIDFunction()
The function to creates a unique value of type uniqueidentifier.
|
String |
getNumericConversionFunction()
Accessor for the function to use for converting to numeric.
|
String |
getOperatorConcat()
An operator in a string expression that concatenates two or more
character or binary strings, columns, or a combination of strings and
column names into one expression (a string operator).
|
String |
getOrderString(org.datanucleus.store.StoreManager storeMgr,
String orderString,
SQLExpression sqlExpr)
Convenience method to allow adaption of an ordering string before applying it.
|
String |
getPatternExpressionAnyCharacter()
The pattern string for representing one character that is expanded in word searches.
|
String |
getPatternExpressionZeroMoreCharacters()
The pattern string for representing zero or more characters that is expanded in word searches.
|
String |
getRangeByLimitEndOfStatementClause(long offset,
long count)
Method to return the SQL to append to the end of the SELECT statement to handle
restriction of ranges using the LIMIT keyword.
|
String |
getRangeByRowNumberColumn()
Method to return the column name to use when handling ranges via
a rownumber on the select using the original method (DB2).
|
String |
getRangeByRowNumberColumn2()
Method to return the column name to use when handling ranges via
a rownumber on the select using the second method (Oracle).
|
int |
getRequiredTransactionIsolationLevel()
Accessor for the "required" transaction isolation level if it has to be a certain value
for this adapter.
|
String |
getSchemaName(Connection conn)
Accessor for the Schema Name for this datastore.
|
String |
getSelectForUpdateText()
Method returning the text to append to the end of the SELECT to perform the equivalent
of "SELECT ...
|
String |
getSelectNewUUIDStmt()
The function to creates a unique value of type uniqueidentifier.
|
String |
getSelectWithLockOption()
The option to specify in "SELECT ...
|
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.
|
String |
getSequenceNextStmt(String sequence_name)
Accessor for the sequence statement to get the next id 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.
|
Collection<String> |
getSupportedOptions()
Accessor for the options that are supported by this datastore adapter and the underlying datastore.
|
String |
getSurrogateForEmptyStrings()
Some databases, Oracle, treats an empty string (0 length) equals null
|
protected long |
getTime(long time,
long nanos) |
int |
getTransactionIsolationForSchemaCreation()
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.
|
SQLText |
getUpdateTableStatement(SQLTable tbl,
SQLText setSQL)
Method to return the SQLText for an UPDATE TABLE statement.
|
Object |
getValueForProperty(String name)
Accessor for a property.
|
String |
getVendorID()
Accessor for the Vendor ID for this datastore.
|
void |
initialiseDatastore(Object conn)
Creates the auxiliary functions/procedures in the schema
|
void |
initialiseTypes(org.datanucleus.store.schema.StoreSchemaHandler handler,
org.datanucleus.store.connection.ManagedConnection mconn)
Initialise the types for this datastore.
|
boolean |
isIdentityFieldDataType(String typeName)
Verifies if the given
typeName is auto incremented by the datastore. |
boolean |
isReservedKeyword(String word)
Tests if a given string is a SQL keyword.
|
boolean |
isStatementCancel(SQLException sqle)
return whether this exception represents a cancelled statement.
|
boolean |
isStatementTimeout(SQLException sqle)
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.
|
Iterator |
iteratorReservedWords()
Iterator for the reserved words constructed from the method
DataBaseMetaData.getSQLKeywords + standard SQL reserved words
|
ForeignKeyInfo |
newFKInfo(ResultSet rs)
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().
|
RDBMSColumnInfo |
newRDBMSColumnInfo(ResultSet rs)
Create a new column info from the current row of the passed ResultSet.
|
SQLTypeInfo |
newSQLTypeInfo(ResultSet rs)
Create a new SQL type info from the current row of the passed ResultSet.
|
void |
removeUnsupportedMappings(org.datanucleus.store.schema.StoreSchemaHandler handler,
org.datanucleus.store.connection.ManagedConnection mconn)
Remove all mappings from the mapping manager that don't have a datastore type initialised.
|
boolean |
sequenceExists(Connection conn,
String catalogName,
String schemaName,
String seqName)
Convenience method to return whether the specified sequence already exists.
|
void |
setProperties(Map<String,Object> props)
Set any properties controlling how the adapter is configured.
|
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.
|
String |
toString()
Method to return this object as a string.
|
boolean |
validToSelectMappingInStatement(SQLStatement stmt,
JavaTypeMapping m)
Method to return if it is valid to select the specified mapping for the specified statement
for this datastore adapter.
|
protected final HashSet<String> reservedKeywords
protected String datastoreProductName
protected String datastoreProductVersion
protected int datastoreMajorVersion
protected int datastoreMinorVersion
protected int datastoreRevisionVersion
protected String identifierQuoteString
protected Collection<String> supportedOptions
protected String driverName
protected String driverVersion
protected int driverMajorVersion
protected int driverMinorVersion
protected int maxTableNameLength
protected int maxConstraintNameLength
protected int maxIndexNameLength
protected int maxColumnNameLength
protected String catalogSeparator
protected BaseDatastoreAdapter(DatabaseMetaData metadata)
metadata
- the database metadata.public void initialiseDatastore(Object conn)
initialiseDatastore
in interface DatastoreAdapter
conn
- the connection to the datastorepublic void initialiseTypes(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn)
initialiseTypes
in interface DatastoreAdapter
handler
- SchemaHandler that we initialise the types formconn
- Managed connection to usepublic String getNameForJDBCType(int jdbcType)
DatastoreAdapter
getNameForJDBCType
in interface DatastoreAdapter
jdbcType
- The jdbc typepublic int getJDBCTypeForName(String typeName)
DatastoreAdapter
getJDBCTypeForName
in interface DatastoreAdapter
typeName
- "jdbc-type" namepublic void setProperties(Map<String,Object> props)
setProperties
in interface DatastoreAdapter
props
- The propertiespublic Object getValueForProperty(String name)
name
- Name of the propertypublic void removeUnsupportedMappings(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn)
removeUnsupportedMappings
in interface DatastoreAdapter
handler
- Schema handlermconn
- Managed connection to useprotected Collection<SQLTypeInfo> getSQLTypeInfoForJdbcType(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn, short jdbcTypeNumber)
handler
- Schema handlermconn
- ConnectionjdbcTypeNumber
- JDBC typeprotected void addSQLTypeForJDBCType(org.datanucleus.store.schema.StoreSchemaHandler handler, org.datanucleus.store.connection.ManagedConnection mconn, short jdbcTypeNumber, SQLTypeInfo sqlType, boolean addIfNotPresent)
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 presentpublic boolean supportsTransactionIsolation(int level)
supportsTransactionIsolation
in interface DatastoreAdapter
level
- The isolation level (as defined by Connection enums).public Collection<String> getSupportedOptions()
getSupportedOptions
in interface DatastoreAdapter
public boolean supportsOption(String option)
supportsOption
in interface DatastoreAdapter
option
- The optionpublic MappingManager getMappingManager(RDBMSStoreManager storeMgr)
getMappingManager
in interface DatastoreAdapter
storeMgr
- The StoreManagerpublic long getAdapterTime(Timestamp time)
DatastoreAdapter
getAdapterTime
in interface DatastoreAdapter
time
- The timestampprotected long getTime(long time, long nanos)
protected int getMiliseconds(long nanos)
public String getDatastoreProductName()
DatastoreAdapter
getDatastoreProductName
in interface DatastoreAdapter
public String getDatastoreProductVersion()
DatastoreAdapter
getDatastoreProductVersion
in interface DatastoreAdapter
public String getDatastoreDriverName()
DatastoreAdapter
getDatastoreDriverName
in interface DatastoreAdapter
public String getDatastoreDriverVersion()
DatastoreAdapter
getDatastoreDriverVersion
in interface DatastoreAdapter
public boolean supportsQueryFetchSize(int size)
supportsQueryFetchSize
in interface DatastoreAdapter
size
- The value to set topublic String getVendorID()
DatastoreAdapter
getVendorID
in interface DatastoreAdapter
public boolean isReservedKeyword(String word)
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.
isReservedKeyword
in interface DatastoreAdapter
word
- The word to test.true
if word is a SQL key word for this DBMS.
The comparison is case-insensitive.SQLConstants
public String getIdentifierQuoteString()
getIdentifierQuoteString
in interface DatastoreAdapter
public int getDriverMajorVersion()
getDriverMajorVersion
in interface DatastoreAdapter
public int getDriverMinorVersion()
getDriverMinorVersion
in interface DatastoreAdapter
public int getDatastoreIdentifierMaxLength(IdentifierType identifierType)
getDatastoreIdentifierMaxLength
in interface DatastoreAdapter
identifierType
- Type of identifier (see IdentifierFactory.TABLE, etc)public int getMaxForeignKeys()
getMaxForeignKeys
in interface DatastoreAdapter
public int getMaxIndexes()
getMaxIndexes
in interface DatastoreAdapter
public Iterator iteratorReservedWords()
iteratorReservedWords
in interface DatastoreAdapter
public RDBMSColumnInfo newRDBMSColumnInfo(ResultSet rs)
DatastoreAdapter
newRDBMSColumnInfo
in interface DatastoreAdapter
rs
- Result Setpublic SQLTypeInfo newSQLTypeInfo(ResultSet rs)
DatastoreAdapter
newSQLTypeInfo
in interface DatastoreAdapter
rs
- ResultSetpublic ForeignKeyInfo newFKInfo(ResultSet rs)
newFKInfo
in interface DatastoreAdapter
rs
- The result set returned from DatabaseMetaData.get??portedKeys()public int getUnlimitedLengthPrecisionValue(SQLTypeInfo typeInfo)
getUnlimitedLengthPrecisionValue
in interface DatastoreAdapter
typeInfo
- the typeInfo object for which the precision value is needed.public boolean isValidPrimaryKeyType(org.datanucleus.metadata.JdbcType datatype)
isValidPrimaryKeyType
in interface DatastoreAdapter
datatype
- The JDBC type.public String getSurrogateForEmptyStrings()
getSurrogateForEmptyStrings
in interface DatastoreAdapter
public int getTransactionIsolationForSchemaCreation()
getTransactionIsolationForSchemaCreation
in interface DatastoreAdapter
public int getRequiredTransactionIsolationLevel()
getRequiredTransactionIsolationLevel
in interface DatastoreAdapter
public String getCatalogName(Connection conn) throws SQLException
getCatalogName
in interface DatastoreAdapter
conn
- Connection to the datastoreSQLException
- Thrown if error occurs in determining the catalog name.public String getSchemaName(Connection conn) throws SQLException
getSchemaName
in interface DatastoreAdapter
conn
- Connection to the datastoreSQLException
- Thrown if error occurs in determining the schema name.public String getCatalogSeparator()
getCatalogSeparator
in interface DatastoreAdapter
public String getSelectWithLockOption()
getSelectWithLockOption
in interface DatastoreAdapter
public String getSelectForUpdateText()
getSelectForUpdateText
in interface DatastoreAdapter
public String getSelectNewUUIDStmt()
getSelectNewUUIDStmt
in interface DatastoreAdapter
public String getNewUUIDFunction()
public String getOrderString(org.datanucleus.store.StoreManager storeMgr, String orderString, SQLExpression sqlExpr)
getOrderString
in interface DatastoreAdapter
storeMgr
- StoreManagerorderString
- The basic ordering stringsqlExpr
- The sql expression being represented herepublic boolean validToSelectMappingInStatement(SQLStatement stmt, JavaTypeMapping m)
validToSelectMappingInStatement
in interface DatastoreAdapter
stmt
- The statementm
- The mapping that we want to selectpublic String getAutoIncrementStmt(Table table, String columnName)
getAutoIncrementStmt
in interface DatastoreAdapter
table
- Name of the table that the autoincrement is forcolumnName
- Name of the column that the autoincrement is forpublic String getAutoIncrementKeyword()
getAutoIncrementKeyword
in interface DatastoreAdapter
public Class getAutoIncrementJavaTypeForType(Class type)
DatastoreAdapter
getAutoIncrementJavaTypeForType
in interface DatastoreAdapter
type
- The type of the member mapping to an IDENTITY columnpublic boolean isIdentityFieldDataType(String typeName)
typeName
is auto incremented by the datastore.isIdentityFieldDataType
in interface DatastoreAdapter
typeName
- the datastore type nametypeName
has values auto incremented by the datastorepublic String getInsertStatementForNoColumns(Table table)
getInsertStatementForNoColumns
in interface DatastoreAdapter
table
- The tablepublic boolean sequenceExists(Connection conn, String catalogName, String schemaName, String seqName)
DatastoreAdapter
sequenceExists
in interface DatastoreAdapter
conn
- Connection to use for checkingcatalogName
- Catalog nameschemaName
- Schema nameseqName
- Name of the sequencepublic String getSequenceCreateStmt(String sequence_name, Integer min, Integer max, Integer start, Integer increment, Integer cache_size)
getSequenceCreateStmt
in interface DatastoreAdapter
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 sequencepublic String getSequenceNextStmt(String sequence_name)
getSequenceNextStmt
in interface DatastoreAdapter
sequence_name
- Name of the sequencepublic ResultSet getExistingIndexes(Connection conn, String catalog, String schema, String table) throws SQLException
getExistingIndexes
in interface DatastoreAdapter
conn
- the JDBC connectioncatalog
- the catalog nameschema
- the schema nametable
- the table nameSQLException
- if an error occurspublic String getCreateTableStatement(TableImpl table, Column[] columns, Properties props, IdentifierFactory factory)
CREATE TABLE FOO ( BAR VARCHAR(30), BAZ INTEGER )
getCreateTableStatement
in interface DatastoreAdapter
table
- The table to create.columns
- The columns of the table.props
- Properties for controlling the table creationfactory
- Factory for identifierspublic String getAddPrimaryKeyStatement(PrimaryKey pk, IdentifierFactory factory)
ALTER TABLE FOO ADD CONSTRAINT FOO_PK PRIMARY KEY (BAR) ALTER TABLE FOO ADD PRIMARY KEY (BAR)
getAddPrimaryKeyStatement
in interface DatastoreAdapter
pk
- An object describing the primary key.factory
- Identifier factorypublic String getAddCandidateKeyStatement(CandidateKey ck, IdentifierFactory factory)
ALTER TABLE FOO ADD CONSTRAINT FOO_CK UNIQUE (BAZ) ALTER TABLE FOO ADD UNIQUE (BAZ)
getAddCandidateKeyStatement
in interface DatastoreAdapter
ck
- An object describing the candidate key.factory
- Identifier factorypublic String getAddForeignKeyStatement(ForeignKey fk, IdentifierFactory factory)
ALTER TABLE FOO ADD CONSTRAINT FOO_FK1 FOREIGN KEY (BAR, BAZ) REFERENCES ABC (COL1, COL2) ALTER TABLE FOO ADD FOREIGN KEY (BAR, BAZ) REFERENCES ABC (COL1, COL2)
getAddForeignKeyStatement
in interface DatastoreAdapter
fk
- An object describing the foreign key.factory
- Identifier factorypublic String getAddColumnStatement(Table table, Column col)
getAddColumnStatement
in interface DatastoreAdapter
table
- The tablecol
- The columnpublic String getCreateIndexStatement(Index idx, IdentifierFactory factory)
CREATE INDEX FOO_N1 ON FOO (BAR,BAZ) [Extended Settings] CREATE UNIQUE INDEX FOO_U1 ON FOO (BAR,BAZ) [Extended Settings]
getCreateIndexStatement
in interface DatastoreAdapter
idx
- An object describing the index.factory
- Identifier factorypublic String getCheckConstraintForValues(DatastoreIdentifier identifier, Object[] values, boolean nullable)
CHECK ("COLUMN" IN ('VAL1','VAL2') OR "COLUMN" IS NULL)
getCheckConstraintForValues
in interface DatastoreAdapter
identifier
- Column identifiervalues
- Valid valuesnullable
- whether the datastore identifier is nullpublic String getCreateDatabaseStatement(String catalogName, String schemaName)
DatastoreAdapter
getCreateDatabaseStatement
in interface DatastoreAdapter
catalogName
- name of the catalogschemaName
- Name of the schemapublic String getDropDatabaseStatement(String catalogName, String schemaName)
DatastoreAdapter
getDropDatabaseStatement
in interface DatastoreAdapter
catalogName
- Name of the catalogschemaName
- Name of the schemapublic String getDropTableStatement(Table table)
DROP TABLE FOO CASCADE
getDropTableStatement
in interface DatastoreAdapter
table
- The table to drop.public String getDropViewStatement(ViewImpl view)
DROP VIEW FOO
getDropViewStatement
in interface DatastoreAdapter
view
- The view to drop.public String getDeleteTableStatement(SQLTable tbl)
DELETE FROM tbl t1
. Doesn't include any where clause.getDeleteTableStatement
in interface DatastoreAdapter
tbl
- The SQLTable to deletepublic SQLText getUpdateTableStatement(SQLTable tbl, SQLText setSQL)
UPDATE tbl t1 SET x1 = val1, x2 = val2
.
Override if the datastore doesn't support that standard syntax.getUpdateTableStatement
in interface DatastoreAdapter
tbl
- The primary tablesetSQL
- The SQLText for the SET componentpublic String getRangeByLimitEndOfStatementClause(long offset, long count)
getRangeByLimitEndOfStatementClause
in interface DatastoreAdapter
offset
- The offset to return fromcount
- The number of items to returnpublic String getRangeByRowNumberColumn()
getRangeByRowNumberColumn
in interface DatastoreAdapter
public String getRangeByRowNumberColumn2()
getRangeByRowNumberColumn2
in interface DatastoreAdapter
public ResultSet getColumns(Connection conn, String catalog, String schema, String table, String columnNamePattern) throws SQLException
getColumns
in interface DatastoreAdapter
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)SQLException
- Thrown if an error occurspublic String toString()
DatastoreAdapter
toString
in interface DatastoreAdapter
toString
in class Object
public String getDatastoreDateStatement()
getDatastoreDateStatement
in interface DatastoreAdapter
public String getPatternExpressionAnyCharacter()
getPatternExpressionAnyCharacter
in interface DatastoreAdapter
public String getPatternExpressionZeroMoreCharacters()
getPatternExpressionZeroMoreCharacters
in interface DatastoreAdapter
public String getEscapePatternExpression()
getEscapePatternExpression
in interface DatastoreAdapter
public String getEscapeCharacter()
getEscapeCharacter
in interface DatastoreAdapter
public String getContinuationString()
public String getNumericConversionFunction()
getNumericConversionFunction
in interface DatastoreAdapter
public String getOperatorConcat()
public boolean isStatementCancel(SQLException sqle)
isStatementCancel
in interface DatastoreAdapter
sqle
- the exceptionpublic boolean isStatementTimeout(SQLException sqle)
isStatementTimeout
in interface DatastoreAdapter
sqle
- the exceptionCopyright © 2015. All rights reserved.