Class AutoAdapter
java.lang.Object
org.apache.cayenne.dba.AutoAdapter
- All Implemented Interfaces:
DbAdapter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DataSourceprotected final List<DbAdapterDetector> protected final AdhocObjectFactory -
Constructor Summary
ConstructorsConstructorDescriptionAutoAdapter(AdhocObjectFactory objectFactory, DataSource dataSource, List<DbAdapterDetector> detectors) -
Method Summary
Modifier and TypeMethodDescriptionvoidbindParameter(CallableStatement statement, CSParameter<?> parameter) Binds an object value to CallableStatement's parameter.voidbindParameter(PreparedStatement statement, PSParameter<?> parameter) Binds an object value to PreparedStatement's parameter.buildAttribute(String name, String typeName, int type, int size, int precision, boolean allowNulls) Creates and returns a DbAttribute based on supplied parameters (usually obtained from database metadata).Returns a SQL string that can be used to create a foreign key constraint for the relationship, or null if foreign keys are not supported.Returns the default primary key generator of the wrapped adapter.createTable(DbEntity entity) Returns a SQL string that can be used to create database table corresponding toentityparameter.voidcreateTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) Append the column type part of a "create table" to the givenStringBuffercreateUniqueConstraint(DbEntity source, Collection<DbAttribute> columns) Returns a DDL string to create a unique constraint over a set of columns, or null if the unique constraints are not supported.protected DbAdapterintReturns the length to use for an unconstrained character column (a CHAR/VARCHAR-family column with no max length) when this database requires a length.protected DbAdapterdetectAdapter(DatabaseMetaData metaData) dropTableStatements(DbEntity table) Returns a collection of SQL statements needed to drop a database table.String[]externalTypesForJdbcType(int type) Deprecated, for removal: This API element is subject to removal in a future version.Returns an instance of SQLAction that should handle the query.protected DbAdapterReturns a proxied DbAdapter, lazily creating it on first invocation.Returns a String used to terminate a batch in command-line tools.Returns theEJBQLTranslatorfor EJBQL to SQL translation.Returns a map of ExtendedTypes that is used to translate values between Java and JDBC layer.getProcedureTranslator(ProcedureQuery query, EntityResolver entityResolver) Returns theProcedureTranslatorfor the given query.Deprecated.getQuotingStrategy(DbEntity entity) Resolves theQuotingStrategyto use for the given entity: this adapter's strategy when the entity's DataMap enables SQL identifier quoting, andQuotingStrategy.NONEotherwise.getSelectTranslator(Select<?> query, EntityResolver entityResolver) Returns theSelectTranslatorfor the given query.protected DbAdapterLoads underlying DbAdapter delegate.nativeColumnTypes(int type) Returns the database-native types that the given JDBCtype(seeTypes) maps to, or null if the type is not supported.intpreferredBindingType(int jdbcType) Returns the JDBC type that this adapter prefers to bind for a given mapped JDBC type.booleanReturnstrueif the target database supports batch updates.booleanReturns true if a target database supports catalogs on reverse engineering.booleanReturns true if a target database supports key autogeneration.booleanReturns true if a target database supports key autogeneration in a batch insert.booleanReturns true if a target database supports UNIQUE constraints.Returns the name of the table type (as returned byDatabaseMetaData.getTableTypes) for a simple user table.Returns the name of the table type (as returned byDatabaseMetaData.getTableTypes) for a view table.booleantypeSupportsLength(int type) booleantypeSupportsScale(int type) Returns true if supplied type can have a scale attribute as a part of column definition.unwrap()Allows the users to get access to the adapter decorated by a given adapter.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DbAdapter
getEjbqlTranslatorFactory, preferredNativeColumnType
-
Field Details
-
objectFactory
-
dataSource
-
detectors
-
-
Constructor Details
-
AutoAdapter
public AutoAdapter(AdhocObjectFactory objectFactory, DataSource dataSource, List<DbAdapterDetector> detectors)
-
-
Method Details
-
getAdapter
Returns a proxied DbAdapter, lazily creating it on first invocation. -
loadAdapter
Loads underlying DbAdapter delegate. -
getSelectTranslator
Description copied from interface:DbAdapterReturns theSelectTranslatorfor the given query. The default implementation ignores the query, but the parameter is retained so adapters can pick a translator based on it.- Specified by:
getSelectTranslatorin interfaceDbAdapter- Since:
- 4.2
-
getProcedureTranslator
public ProcedureTranslator getProcedureTranslator(ProcedureQuery query, EntityResolver entityResolver) Description copied from interface:DbAdapterReturns theProcedureTranslatorfor the given query. The default implementation ignores the query, but the parameter is retained so adapters can pick a translator based on it.- Specified by:
getProcedureTranslatorin interfaceDbAdapter- Since:
- 5.0
-
getBatchTerminator
Description copied from interface:DbAdapterReturns a String used to terminate a batch in command-line tools. E.g. ";" on Oracle or "go" on Sybase.- Specified by:
getBatchTerminatorin interfaceDbAdapter
-
getSqlTreeProcessor
- Specified by:
getSqlTreeProcessorin interfaceDbAdapter- Returns:
SQLTreeProcessorthat can adjust SQL tree to specific database flavour
-
getAction
-
supportsUniqueConstraints
public boolean supportsUniqueConstraints()Description copied from interface:DbAdapterReturns true if a target database supports UNIQUE constraints.- Specified by:
supportsUniqueConstraintsin interfaceDbAdapter
-
supportsCatalogsOnReverseEngineering
public boolean supportsCatalogsOnReverseEngineering()Description copied from interface:DbAdapterReturns true if a target database supports catalogs on reverse engineering.- Specified by:
supportsCatalogsOnReverseEngineeringin interfaceDbAdapter
-
supportsGeneratedKeys
public boolean supportsGeneratedKeys()Description copied from interface:DbAdapterReturns true if a target database supports key autogeneration. This feature also requires JDBC3-compliant driver.- Specified by:
supportsGeneratedKeysin interfaceDbAdapter
-
supportsGeneratedKeysForBatchInserts
public boolean supportsGeneratedKeysForBatchInserts()Description copied from interface:DbAdapterReturns true if a target database supports key autogeneration in a batch insert.- Specified by:
supportsGeneratedKeysForBatchInsertsin interfaceDbAdapter- Since:
- 4.2
- See Also:
-
supportsBatchUpdates
public boolean supportsBatchUpdates()Description copied from interface:DbAdapterReturnstrueif the target database supports batch updates.- Specified by:
supportsBatchUpdatesin interfaceDbAdapter
-
typeSupportsLength
public boolean typeSupportsLength(int type) - Specified by:
typeSupportsLengthin interfaceDbAdapter
-
typeSupportsScale
public boolean typeSupportsScale(int type) Description copied from interface:DbAdapterReturns true if supplied type can have a scale attribute as a part of column definition.- Specified by:
typeSupportsScalein interfaceDbAdapter- Since:
- 5.0
-
defaultCharColumnLength
public int defaultCharColumnLength()Description copied from interface:DbAdapterReturns the length to use for an unconstrained character column (a CHAR/VARCHAR-family column with no max length) when this database requires a length.- Specified by:
defaultCharColumnLengthin interfaceDbAdapter- Since:
- 5.0
-
dropTableStatements
Description copied from interface:DbAdapterReturns a collection of SQL statements needed to drop a database table.- Specified by:
dropTableStatementsin interfaceDbAdapter
-
createTable
Description copied from interface:DbAdapterReturns a SQL string that can be used to create database table corresponding toentityparameter.- Specified by:
createTablein interfaceDbAdapter
-
createUniqueConstraint
Description copied from interface:DbAdapterReturns a DDL string to create a unique constraint over a set of columns, or null if the unique constraints are not supported.- Specified by:
createUniqueConstraintin interfaceDbAdapter
-
createFkConstraint
Description copied from interface:DbAdapterReturns a SQL string that can be used to create a foreign key constraint for the relationship, or null if foreign keys are not supported.- Specified by:
createFkConstraintin interfaceDbAdapter
-
externalTypesForJdbcType
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:DbAdapterReturns an array of RDBMS types that can be used with JDBCtype. Valid JDBC types are defined in java.sql.Types.- Specified by:
externalTypesForJdbcTypein interfaceDbAdapter
-
nativeColumnTypes
Description copied from interface:DbAdapterReturns the database-native types that the given JDBCtype(seeTypes) maps to, or null if the type is not supported. The first variant is used for column DDL.- Specified by:
nativeColumnTypesin interfaceDbAdapter
-
getExtendedTypes
Description copied from interface:DbAdapterReturns a map of ExtendedTypes that is used to translate values between Java and JDBC layer.- Specified by:
getExtendedTypesin interfaceDbAdapter
-
createPkGenerator
Returns the default primary key generator of the wrapped adapter.- Specified by:
createPkGeneratorin interfaceDbAdapter
-
buildAttribute
public DbAttribute buildAttribute(String name, String typeName, int type, int size, int precision, boolean allowNulls) Description copied from interface:DbAdapterCreates and returns a DbAttribute based on supplied parameters (usually obtained from database metadata).- Specified by:
buildAttributein interfaceDbAdapter- Parameters:
name- database column nametypeName- database specific type name, may be used as a hint to determine the right JDBC type.type- JDBC column typesize- database column size (ignored if less than zero)precision- database column scale, i.e. the number of decimal digits (ignored if less than zero)allowNulls- database column nullable parameter
-
bindParameter
Description copied from interface:DbAdapterBinds an object value to PreparedStatement's parameter.- Specified by:
bindParameterin interfaceDbAdapter- Throws:
Exception
-
bindParameter
Description copied from interface:DbAdapterBinds an object value to CallableStatement's parameter.- Specified by:
bindParameterin interfaceDbAdapter- Throws:
Exception
-
preferredBindingType
public int preferredBindingType(int jdbcType) Description copied from interface:DbAdapterReturns the JDBC type that this adapter prefers to bind for a given mapped JDBC type. The default implementation is an identity function; adapters whose drivers require a different type (e.g. remapping theN*character types to their non-national counterparts) override this. The returned type is resolved into thePSParameterat binding creation time, so it matches the type actually sent to the PreparedStatement.- Specified by:
preferredBindingTypein interfaceDbAdapter- Since:
- 5.0
-
tableTypeForTable
Description copied from interface:DbAdapterReturns the name of the table type (as returned byDatabaseMetaData.getTableTypes) for a simple user table.- Specified by:
tableTypeForTablein interfaceDbAdapter
-
tableTypeForView
Description copied from interface:DbAdapterReturns the name of the table type (as returned byDatabaseMetaData.getTableTypes) for a view table.- Specified by:
tableTypeForViewin interfaceDbAdapter
-
createTableAppendColumn
Description copied from interface:DbAdapterAppend the column type part of a "create table" to the givenStringBuffer- Specified by:
createTableAppendColumnin interfaceDbAdapter- Parameters:
sqlBuffer- theStringBufferto append the column type tocolumn- theDbAttributedefining the column to append type for
-
getQuotingStrategy
Deprecated.Description copied from interface:DbAdapterReturns the SQL identifier quoting style (start/end quote characters) for this adapter. Whether quoting is applied is decided by the caller, which uses this instance when quoting is enabled andQuotingStrategy.NONEotherwise.- Specified by:
getQuotingStrategyin interfaceDbAdapter
-
getQuotingStrategy
Description copied from interface:DbAdapterResolves theQuotingStrategyto use for the given entity: this adapter's strategy when the entity's DataMap enables SQL identifier quoting, andQuotingStrategy.NONEotherwise.- Specified by:
getQuotingStrategyin interfaceDbAdapter- Since:
- 5.0
-
unwrap
-
getEjbqlTranslator
Description copied from interface:DbAdapterReturns theEJBQLTranslatorfor EJBQL to SQL translation.- Specified by:
getEjbqlTranslatorin interfaceDbAdapter- Since:
- 5.0
-
getSystemCatalogs
- Specified by:
getSystemCatalogsin interfaceDbAdapter- Returns:
- list of system catalogs
-
getSystemSchemas
- Specified by:
getSystemSchemasin interfaceDbAdapter- Returns:
- list of system schemas
-
detectAdapter
- Throws:
SQLException
-
defaultAdapter
-