|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.dba.JdbcAdapter
org.apache.cayenne.dba.mysql.MySQLAdapter
public class MySQLAdapter
DbAdapter implementation for MySQL RDBMS.
Foreign key constraints are supported by InnoDB engine and NOT supported by
MyISAM engine. This adapter by default assumes MyISAM, so
org.apache.cayenne.dba.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.
Field Summary | |
---|---|
protected String |
storageEngine
|
protected boolean |
supportsFkConstraints
|
Fields inherited from class org.apache.cayenne.dba.JdbcAdapter |
---|
batchQueryBuilderFactory, caseInsensitiveCollations, CI_PROPERTY, ejbqlTranslatorFactory, extendedTypes, logger, quotingStrategy, resourceLocator, supportsBatchUpdates, supportsGeneratedKeys, supportsUniqueConstraints, typesHandler |
Constructor Summary | |
---|---|
MySQLAdapter(RuntimeProperties runtimeProperties,
List<ExtendedType> defaultExtendedTypes,
List<ExtendedType> userExtendedTypes,
List<ExtendedTypeFactory> extendedTypeFactories)
|
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. |
protected QuotingStrategy |
createQuotingStrategy()
|
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. |
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()
|
MergerFactory |
mergerFactory()
|
void |
setStorageEngine(String engine)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected String storageEngine
protected boolean supportsFkConstraints
Constructor Detail |
---|
public MySQLAdapter(RuntimeProperties runtimeProperties, List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories)
Method Detail |
---|
protected QuotingStrategy createQuotingStrategy()
createQuotingStrategy
in class JdbcAdapter
public QualifierTranslator getQualifierTranslator(QueryAssembler queryAssembler)
JdbcAdapter
getQualifierTranslator
in interface DbAdapter
getQualifierTranslator
in class JdbcAdapter
public SQLAction getAction(Query query, DataNode node)
getAction
in interface DbAdapter
getAction
in class JdbcAdapter
public Collection<String> dropTableStatements(DbEntity table)
DbAdapter
dropTableStatements
in interface DbAdapter
dropTableStatements
in class JdbcAdapter
protected void configureExtendedTypes(ExtendedTypeMap map)
configureExtendedTypes
in class JdbcAdapter
public DbAttribute buildAttribute(String name, String typeName, int type, int size, int precision, boolean allowNulls)
DbAdapter
buildAttribute
in interface DbAdapter
buildAttribute
in class JdbcAdapter
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 parameterprotected PkGenerator createPkGenerator()
createPkGenerator
in class JdbcAdapter
protected EJBQLTranslatorFactory createEJBQLTranslatorFactory()
JdbcAdapter
EJBQLTranslatorFactory
used to generate
visitors for EJBQL to SQL translations. This method should be overriden
by subclasses that need to customize EJBQL generation.
createEJBQLTranslatorFactory
in class JdbcAdapter
public String createTable(DbEntity entity)
createTable
in interface DbAdapter
createTable
in class JdbcAdapter
protected void createTableAppendPKClause(StringBuffer sqlBuffer, DbEntity entity)
createTableAppendPKClause
in class JdbcAdapter
public void createTableAppendColumn(StringBuffer sqlBuffer, DbAttribute column)
createTableAppendColumn
in interface DbAdapter
createTableAppendColumn
in class JdbcAdapter
sqlBuffer
- the StringBuffer
to append the column type tocolumn
- the DbAttribute
defining the column to append type forpublic MergerFactory mergerFactory()
mergerFactory
in interface DbAdapter
mergerFactory
in class JdbcAdapter
public String getStorageEngine()
public void setStorageEngine(String engine)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |