Class MySQLAdapter
java.lang.Object
org.apache.cayenne.dba.JdbcAdapter
org.apache.cayenne.dba.mysql.MySQLAdapter
- All Implemented Interfaces:
DbAdapter
DbAdapter implementation for MySQL RDBMS.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMySQLAdapter(RuntimeProperties runtimeProperties, List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ValueObjectTypeRegistry valueObjectTypeRegistry) -
Method Summary
Modifier and TypeMethodDescriptionbuildAttribute(String name, String typeName, int type, int maxLength, int scale, boolean allowNulls) Creates and returns a DbAttribute based on supplied parameters (usually obtained from database metadata).protected voidInstalls appropriate ExtendedTypes used as converters for passing values between JDBC and Java layers.protected EJBQLTranslatorCreates and returns anEJBQLTranslatorused to generate visitors for EJBQL to SQL translations.protected NativeColumnType[]Returns the database-native types supported by this adapter.Returns aMySQLPkGenerator.protected QuotingStrategycreateTable(DbEntity entity) Overrides super implementation to explicitly set table engine to InnoDB if FK constraints are supported by this adapter.voidcreateTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column) Appends AUTO_INCREMENT clause to the column definition for generated columns.protected voidcreateTableAppendPKClause(StringBuffer sqlBuffer, DbEntity entity) Customizes PK clause semantics to ensure that generated columns are in the beginning of the PK definition, as this seems to be a requirement for InnoDB tables.dropTableStatements(DbEntity table) Returns a collection of SQL statements needed to drop a database table.Uses special action builder to create the right action.getProcedureTranslator(ProcedureQuery query, EntityResolver entityResolver) Returns theProcedureTranslatorfor the given query.intpreferredBindingType(int jdbcType) Returns the JDBC type that this adapter prefers to bind for a given mapped JDBC type.voidsetStorageEngine(String engine) booleantypeSupportsLength(int type) Returns true if supplied type can have a length attribute as a part of column definitionMethods inherited from class JdbcAdapter
bind, bindParameter, bindParameter, createFkConstraint, createUniqueConstraint, defaultCharColumnLength, externalTypesForJdbcType, getBatchTerminator, getEjbqlTranslator, getExtendedTypes, getQuotingStrategy, getQuotingStrategy, getSelectTranslator, getSQLLogger, getSystemSchemas, getType, initExtendedTypes, nativeColumnTypes, setEjbqlTranslator, setEjbqlTranslatorFactory, setSupportsBatchUpdates, setSupportsGeneratedKeys, setSupportsUniqueConstraints, sizeAndPrecision, sizeAndScale, supportsBatchUpdates, supportsCatalogsOnReverseEngineering, supportsGeneratedKeys, supportsUniqueConstraints, tableTypeForTable, tableTypeForView, typeSupportsScale, unwrapMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DbAdapter
getEjbqlTranslatorFactory, preferredNativeColumnType, supportsGeneratedKeysForBatchInserts
-
Field Details
-
storageEngine
-
-
Constructor Details
-
MySQLAdapter
public MySQLAdapter(RuntimeProperties runtimeProperties, List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ValueObjectTypeRegistry valueObjectTypeRegistry)
-
-
Method Details
-
createNativeTypes
Description copied from class:JdbcAdapterReturns the database-native types supported by this adapter.- Overrides:
createNativeTypesin classJdbcAdapter
-
createQuotingStrategy
- Overrides:
createQuotingStrategyin classJdbcAdapter
-
createPkGenerator
Returns aMySQLPkGenerator.- Specified by:
createPkGeneratorin interfaceDbAdapter- Overrides:
createPkGeneratorin classJdbcAdapter
-
getSqlTreeProcessor
- Specified by:
getSqlTreeProcessorin interfaceDbAdapter- Overrides:
getSqlTreeProcessorin classJdbcAdapter- Returns:
SQLTreeProcessorthat can adjust SQL tree to specific database flavour- Since:
- 4.2
-
getAction
-
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- Overrides:
getProcedureTranslatorin classJdbcAdapter- Since:
- 5.0
-
dropTableStatements
Description copied from interface:DbAdapterReturns a collection of SQL statements needed to drop a database table.- Specified by:
dropTableStatementsin interfaceDbAdapter- Overrides:
dropTableStatementsin classJdbcAdapter- Since:
- 3.0
-
configureExtendedTypes
Installs appropriate ExtendedTypes used as converters for passing values between JDBC and Java layers.- Overrides:
configureExtendedTypesin classJdbcAdapter
-
buildAttribute
public DbAttribute buildAttribute(String name, String typeName, int type, int maxLength, int scale, boolean allowNulls) Description copied from interface:DbAdapterCreates and returns a DbAttribute based on supplied parameters (usually obtained from database metadata).- Specified by:
buildAttributein interfaceDbAdapter- Overrides:
buildAttributein classJdbcAdapter- Parameters:
name- database column nametypeName- database specific type name, may be used as a hint to determine the right JDBC type.type- JDBC column typemaxLength- database column size (ignored if less than zero)scale- database column scale, i.e. the number of decimal digits (ignored if less than zero)allowNulls- database column nullable parameter
-
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. -
createEJBQLTranslator
Description copied from class:JdbcAdapterCreates and returns anEJBQLTranslatorused to generate visitors for EJBQL to SQL translations. This method should be overriden by subclasses that need to customize EJBQL generation.- Overrides:
createEJBQLTranslatorin classJdbcAdapter- Since:
- 3.0
-
createTable
Overrides super implementation to explicitly set table engine to InnoDB if FK constraints are supported by this adapter.- Specified by:
createTablein interfaceDbAdapter- Overrides:
createTablein classJdbcAdapter
-
createTableAppendPKClause
Customizes PK clause semantics to ensure that generated columns are in the beginning of the PK definition, as this seems to be a requirement for InnoDB tables.- Overrides:
createTableAppendPKClausein classJdbcAdapter- Since:
- 1.2
-
createTableAppendColumn
Appends AUTO_INCREMENT clause to the column definition for generated columns.- Specified by:
createTableAppendColumnin interfaceDbAdapter- Overrides:
createTableAppendColumnin classJdbcAdapter- Parameters:
sqlBuffer- theStringBufferto append the column type tocolumn- theDbAttributedefining the column to append type for
-
typeSupportsLength
public boolean typeSupportsLength(int type) Description copied from class:JdbcAdapterReturns true if supplied type can have a length attribute as a part of column definition- Specified by:
typeSupportsLengthin interfaceDbAdapter- Overrides:
typeSupportsLengthin classJdbcAdapter
-
getSystemCatalogs
- Specified by:
getSystemCatalogsin interfaceDbAdapter- Overrides:
getSystemCatalogsin classJdbcAdapter- Returns:
- list of system catalogs
-
getStorageEngine
- Since:
- 3.0
-
setStorageEngine
- Since:
- 3.0
-