Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.dba.mysql
Class MySQLAdapter

    java.lang.Object
      org.apache.cayenne.dba.JdbcAdapter
          org.apache.cayenne.dba.mysql.MySQLAdapter

All Implemented Interfaces:
  DbAdapter

    public class MySQLAdapter

extends JdbcAdapter

DbAdapter implementation for MySQL RDBMS.

### Foreign Key Constraint Handling

Foreign key constraints are supported by InnoDB engine and NOT supported by MyISAM engine. This adapter by default assumes MyISAM, so `JdbcAdapter.supportsFkConstraints()` will return false. Users can manually change this by calling setSupportsFkConstraints(true) or better by using an `AutoAdapter`, i.e. not entering the adapter name at all for the DataNode, letting Cayenne guess it in runtime. In the later case Cayenne will check the table_type MySQL variable to detect whether InnoDB is the default, and configure the adapter accordingly.

### Sample Connection Settings

- Adapter name: org.apache.cayenne.dba.mysql.MySQLAdapter
- DB URL: jdbc:mysql://serverhostname/dbname
- Driver Class: com.mysql.jdbc.Driver

Field Summary
`protected String` | `storageEngine`

Fields inherited from class org.apache.cayenne.dba.JdbcAdapter
`ejbqlTranslatorFactory, extendedTypes, identifiersEndQuote, identifiersStartQuote, pkGenerator, supportsBatchUpdates, supportsFkConstraints, supportsGeneratedKeys, supportsUniqueConstraints, typesHandler`

Constructor Summary
`MySQLAdapter()`

Method Summary
`DbAttribute` | `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 meta data).
`protected void` | `configureExtendedTypes(ExtendedTypeMap map)` Installs appropriate ExtendedTypes used as converters for passing values between JDBC and Java layers.
`protected EJBQLTranslatorFactory` | `createEJBQLTranslatorFactory()` Creates and returns an `EJBQLTranslatorFactory` used to generate visitors for EJBQL to SQL translations.
`protected PkGenerator` | `createPkGenerator()` Creates and returns a primary key generator.
`String` | `createTable(DbEntity entity)` Overrides super implementation to explicitly set table engine to InnoDB if FK constraints are supported by this adapter.
`void` | `createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column)` Appends AUTO_INCREMENT clause to the column definition for generated columns.
`protected void` | `createTableAppendPKClause(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.
`String` | `dropTable(DbEntity table)` Deprecated. since 3.0
`Collection<String>` | `dropTableStatements(DbEntity table)` Returns a collection of SQL statements needed to drop a database table.
`SQLAction` | `getAction(Query query, DataNode node)` Uses special action builder to create the right action.
`QualifierTranslator` | `getQualifierTranslator(QueryAssembler queryAssembler)` Creates and returns a default implementation of a qualifier translator.
`String` | `getStorageEngine()`
`void` | `initIdentifiersQuotes()`
`MergerFactory` | `mergerFactory()`
`void` | `setStorageEngine(String engine)`

Methods inherited from class org.apache.cayenne.dba.JdbcAdapter
`bindParameter, createFkConstraint, createUniqueConstraint, externalTypesForJdbcType, findAdapterResource, findResource, getBatchTerminator, getEjbqlTranslatorFactory, getExtendedTypes, getIdentifiersEndQuote, getIdentifiersStartQuote, getPkGenerator, getQuotingStrategy, setEjbqlTranslatorFactory, setPkGenerator, setSupportsBatchUpdates, setSupportsFkConstraints, setSupportsGeneratedKeys, setSupportsUniqueConstraints, supportsBatchUpdates, supportsFkConstraints, supportsGeneratedKeys, supportsUniqueConstraints, tableTypeForTable, tableTypeForView`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### storageEngine

    protected String storageEngine

Constructor Detail

### MySQLAdapter

    public MySQLAdapter()

Method Detail

### initIdentifiersQuotes

    public void initIdentifiersQuotes()

  Overrides:
    `initIdentifiersQuotes` in class `JdbcAdapter`

### getQualifierTranslator

    public QualifierTranslator getQualifierTranslator(QueryAssembler queryAssembler)

  Description copied from class: `JdbcAdapter`
  Creates and returns a default implementation of a qualifier translator.

  Specified by:
    `getQualifierTranslator` in interface `DbAdapter`
  Overrides:
    `getQualifierTranslator` in class `JdbcAdapter`

### getAction

    public SQLAction getAction(Query query,
                               DataNode node)

  Uses special action builder to create the right action.

  Specified by:
    `getAction` in interface `DbAdapter`
  Overrides:
    `getAction` in class `JdbcAdapter`
  Since:
    1.2

### dropTable

    public String dropTable(DbEntity table)

  Deprecated. since 3.0

  Description copied from class: `JdbcAdapter`
  Returns a SQL string to drop a table corresponding to table DbEntity.

  Specified by:
    `dropTable` in interface `DbAdapter`
  Overrides:
    `dropTable` in class `JdbcAdapter`

### dropTableStatements

    public Collection<String> dropTableStatements(DbEntity table)

  Description copied from interface: `DbAdapter`
  Returns a collection of SQL statements needed to drop a database table.

  Specified by:
    `dropTableStatements` in interface `DbAdapter`
  Overrides:
    `dropTableStatements` in class `JdbcAdapter`
  Since:
    3.0

### configureExtendedTypes

    protected void configureExtendedTypes(ExtendedTypeMap map)

  Installs appropriate ExtendedTypes used as converters for passing values between JDBC and Java layers.

  Overrides:
    `configureExtendedTypes` in class `JdbcAdapter`

### buildAttribute

    public DbAttribute buildAttribute(String name,
                                      String typeName,
                                      int type,
                                      int size,
                                      int precision,
                                      boolean allowNulls)

  Description copied from interface: `DbAdapter`
  Creates and returns a DbAttribute based on supplied parameters (usually obtained from database meta data).

  Specified by:
    `buildAttribute` in interface `DbAdapter`
  Overrides:
    `buildAttribute` in class `JdbcAdapter`
  Parameters:
    `name` - database column name
    `typeName` - database specific type name, may be used as a hint to determine the right JDBC type.
    `type` - JDBC column type
    `size` - 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

### createPkGenerator

    protected PkGenerator createPkGenerator()

  Creates and returns a primary key generator. Overrides superclass implementation to return an instance of MySQLPkGenerator that does the correct table locking.

  Overrides:
    `createPkGenerator` in class `JdbcAdapter`

### createEJBQLTranslatorFactory

    protected EJBQLTranslatorFactory createEJBQLTranslatorFactory()

  Description copied from class: `JdbcAdapter`
  Creates and returns an `EJBQLTranslatorFactory` used to generate visitors for EJBQL to SQL translations. This method should be overriden by subclasses that need to customize EJBQL generation.

  Overrides:
    `createEJBQLTranslatorFactory` in class `JdbcAdapter`
  Since:
    3.0

### createTable

    public String createTable(DbEntity entity)

  Overrides super implementation to explicitly set table engine to InnoDB if FK constraints are supported by this adapter.

  Specified by:
    `createTable` in interface `DbAdapter`
  Overrides:
    `createTable` in class `JdbcAdapter`

### createTableAppendPKClause

    protected void createTableAppendPKClause(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.

  Overrides:
    `createTableAppendPKClause` in class `JdbcAdapter`
  Since:
    1.2

### createTableAppendColumn

    public void createTableAppendColumn(StringBuffer sqlBuffer,
                                        DbAttribute column)

  Appends AUTO_INCREMENT clause to the column definition for generated columns.

  Specified by:
    `createTableAppendColumn` in interface `DbAdapter`
  Overrides:
    `createTableAppendColumn` in class `JdbcAdapter`
  Parameters:
    `sqlBuffer` - the `StringBuffer` to append the column type to
    `column` - the `DbAttribute` defining the column to append type for

### mergerFactory

    public MergerFactory mergerFactory()

  Specified by:
    `mergerFactory` in interface `DbAdapter`
  Overrides:
    `mergerFactory` in class `JdbcAdapter`

### getStorageEngine

    public String getStorageEngine()

  Since:
    3.0

### setStorageEngine

    public void setStorageEngine(String engine)

  Since:
    3.0

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2011 Apache Cayenne. All Rights Reserved.