org.apache.openjpa.jdbc.sql
Class MySQLDictionary

java.lang.Object
  extended by org.apache.openjpa.jdbc.sql.DBDictionary
      extended by org.apache.openjpa.jdbc.sql.MySQLDictionary
All Implemented Interfaces:
JoinSyntaxes, Configurable, ConnectionDecorator, LoggingConnectionDecorator.SQLWarningHandler

public class MySQLDictionary
extends DBDictionary

Dictionary for MySQL.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
DBDictionary.SerializedData
 
Field Summary
 boolean driverDeserializesBlobs
          Whether the driver automatically deserializes blobs.
 boolean optimizeMultiTableDeletes
          Whether to inline multi-table bulk-delete operations into MySQL's combined DELETE FROM foo, bar, baz syntax.
 String tableType
          The MySQL table type to use when creating tables; defaults to innodb.
 boolean useClobs
          Whether to use clobs.
 
Fields inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
allowsAliasInBulkClause, arrayTypeName, autoAssignClause, autoAssignTypeName, batchLimit, bigintTypeName, binaryTypeName, bitLengthFunction, bitTypeName, blobBufferSize, blobTypeName, booleanTypeName, castFunction, catalogSeparator, CENTI, characterColumnSize, charTypeName, clobBufferSize, clobTypeName, closePoolSQL, concatenateDelimiter, concatenateFunction, conf, connected, CONS_NAME_AFTER, CONS_NAME_BEFORE, CONS_NAME_MID, constraintNameMode, createPrimaryKeys, crossJoinClause, currentDateFunction, currentTimeFunction, currentTimestampFunction, datePrecision, dateTypeName, DECI, decimalTypeName, distinctCountColumnSeparator, distinctTypeName, doubleTypeName, driverVendor, dropTableSQL, EMPTY_STRING_LIST, fixedSizeTypeNames, fixedSizeTypeNameSet, floatTypeName, forUpdateClause, getStringVal, inClauseLimit, initializationSQL, innerJoinClause, integerTypeName, javaObjectTypeName, joinSyntax, lastGeneratedKeyQuery, log, longVarbinaryTypeName, longVarcharTypeName, maxAutoAssignNameLength, maxColumnNameLength, maxConstraintNameLength, maxEmbeddedBlobSize, maxEmbeddedClobSize, maxIndexesPerTable, maxIndexNameLength, maxTableNameLength, MICRO, MILLI, NAME_ANY, NAME_SEQUENCE, NAME_TABLE, NANO, nextSequenceQuery, NO_BATCH, nullTypeName, numericTypeName, otherTypeName, outerJoinClause, platform, RANGE_POST_DISTINCT, RANGE_POST_LOCK, RANGE_POST_SELECT, RANGE_PRE_DISTINCT, rangePosition, realTypeName, refTypeName, requiresAliasForSubselect, requiresAutoCommitForMetaData, requiresCastForComparisons, requiresCastForMathFunctions, requiresConditionForCrossJoin, requiresTargetForDelete, reservedWords, reservedWordSet, SCHEMA_CASE_LOWER, SCHEMA_CASE_PRESERVE, SCHEMA_CASE_UPPER, schemaCase, searchStringEscape, SEC, selectWords, selectWordSet, sequenceNameSQL, sequenceSchemaSQL, sequenceSQL, simulateLocking, smallintTypeName, SQL_STATE_CODES, storageLimitationsFatal, storeCharsAsNumbers, storeLargeNumbersAsStrings, stringLengthFunction, structTypeName, substringFunctionName, supportsAlterTableWithAddColumn, supportsAlterTableWithDropColumn, supportsAutoAssign, supportsCascadeDeleteAction, supportsCascadeUpdateAction, supportsComments, supportsCorrelatedSubselect, supportsDefaultDeleteAction, supportsDefaultUpdateAction, supportsDeferredConstraints, supportsForeignKeys, supportsHaving, supportsLockingWithDistinctClause, supportsLockingWithInnerJoin, supportsLockingWithMultipleTables, supportsLockingWithOrderClause, supportsLockingWithOuterJoin, supportsLockingWithSelectRange, supportsModOperator, supportsMultipleNontransactionalResultSets, supportsNullDeleteAction, supportsNullTableForGetColumns, supportsNullTableForGetImportedKeys, supportsNullTableForGetIndexInfo, supportsNullTableForGetPrimaryKeys, supportsNullUpdateAction, supportsQueryTimeout, supportsRestrictDeleteAction, supportsRestrictUpdateAction, supportsSchemaForGetColumns, supportsSchemaForGetTables, supportsSelectEndIndex, supportsSelectForUpdate, supportsSelectStartIndex, supportsSubselect, supportsTimestampNanos, supportsUniqueConstraints, supportsXMLColumn, systemSchemas, systemSchemaSet, systemTables, systemTableSet, tableForUpdateClause, tableTypes, timestampTypeName, timeTypeName, tinyintTypeName, toLowerCaseFunction, toUpperCaseFunction, trimBothFunction, trimLeadingFunction, trimTrailingFunction, typeModifierSet, UNLIMITED, useGetBestRowIdentifierForPrimaryKeys, useGetBytesForBlobs, useGetObjectForBlobs, useGetStringForClobs, useSchemaName, useSetBytesForBlobs, useSetStringForClobs, validationSQL, varbinaryTypeName, varcharTypeName, VENDOR_DATADIRECT, VENDOR_OTHER, xmlTypeName
 
Fields inherited from interface org.apache.openjpa.jdbc.sql.JoinSyntaxes
SYNTAX_DATABASE, SYNTAX_SQL92, SYNTAX_TRADITIONAL
 
Constructor Summary
MySQLDictionary()
           
 
Method Summary
protected  void appendSelectRange(SQLBuffer buf, long start, long end, boolean subselect)
          If this dictionary can select ranges, use this method to append the range SQL.
 void connectedConfiguration(Connection conn)
          This method is called when the dictionary first sees any connection.
 String[] getAddPrimaryKeySQL(PrimaryKey pk)
          Return a series of SQL statements to add the given primary key to its table.
 Object getBlobObject(ResultSet rs, int column, JDBCStore store)
          Convert the specified column of the SQL ResultSet to the proper java type.
 String[] getCreateTableSQL(Table table)
          Return a series of SQL statements to create the given table, complete with columns.
 String[] getDeleteTableContentsSQL(Table[] tables)
          Create SQL to delete the contents of the specified tables.
 String[] getDropIndexSQL(Index index)
          Return a series of SQL statements to drop the given index.
protected  String getForeignKeyConstraintSQL(ForeignKey fk)
          Return the declaration SQL for the given foreign key, or null if it is not supported.
 int getPreferredType(int type)
          Return the preferred Types type for the given one.
protected  Column newColumn(ResultSet colMeta)
          Create a new column from the information in the schema metadata.
 
Methods inherited from class org.apache.openjpa.jdbc.sql.DBDictionary
addCastAsType, appendCast, appendLength, appendNumericCast, appendSelect, appendSize, appendUpdates, appendXmlComparison, assertSupport, calculateValue, canOuterJoin, closeDataSource, comment, comparison, convertSchemaCase, copy, copy, createIndexIfNecessary, decorate, deleteStream, endConfiguration, executeQuery, getAddColumnSQL, getAddForeignKeySQL, getArray, getAsciiStream, getBatchLimit, getBigDecimal, getBigInteger, getBinaryStream, getBlob, getBoolean, getByte, getBytes, getCalendar, getCastFunction, getCatalogNameForMetadata, getChar, getCharacterStream, getClob, getClobString, getColumnNameForMetadata, getColumns, getCreateIndexSQL, getCreateSequenceSQL, getDate, getDate, getDeclareColumnSQL, getDeleteTargets, getDouble, getDropColumnSQL, getDropForeignKeySQL, getDropPrimaryKeySQL, getDropSequenceSQL, getDropTableSQL, getFloat, getForUpdateClause, getFrom, getFromSelect, getFullName, getFullName, getFullName, getGeneratedKey, getGeneratedKeySequenceName, getImportedKeys, getIndexInfo, getInt, getJDBCType, getKey, getLOBStream, getLocale, getLong, getNumber, getObject, getPlaceholderValueString, getPrimaryKeyConstraintSQL, getPrimaryKeys, getPrimaryKeysFromBestRowIdentifier, getPrimaryKeysFromGetPrimaryKeys, getRef, getSchemaCase, getSchemaNameForMetadata, getSelectOperation, getSelects, getSequence, getSequences, getSequencesSQL, getShort, getSQLStates, getString, getTableNameForMetadata, getTables, getTime, getTimestamp, getTypeName, getTypeName, getUniqueConstraintSQL, getValidColumnName, getValidColumnName, getValidForeignKeyName, getValidIndexName, getValidPrimaryKeyName, getValidSequenceName, getValidTableName, getValidUniqueName, getVersionColumn, getWhere, handleWarning, indexOf, insertBlobForStreamingLoad, insertClobForStreamingLoad, insertSize, isSelect, isSystemIndex, isSystemSequence, isSystemTable, makeNameValid, makeNameValid, mathFunction, newForeignKey, newIndex, newPrimaryKey, newSequence, newStoreException, newTable, prepareStatement, putBytes, putChars, putString, refSchemaComponents, serialize, setArray, setAsciiStream, setBatchLimit, setBigDecimal, setBigInteger, setBinaryStream, setBlob, setBlobObject, setBoolean, setByte, setBytes, setCalendar, setChar, setCharacterStream, setClob, setClobString, setConfiguration, setDate, setDate, setDouble, setFloat, setInt, setJoinSyntax, setLocale, setLong, setNull, setNumber, setObject, setRef, setShort, setString, setTime, setTimestamp, setTyped, setUnknown, shorten, startConfiguration, storageWarning, substring, supportsDeferredForeignKeyConstraints, supportsDeferredUniqueConstraints, supportsDeleteAction, supportsLocking, supportsRandomAccessResultSet, supportsUpdateAction, toBulkOperation, toDelete, toNativeJoin, toOperation, toOperation, toSelect, toSelect, toSelect, toSelect, toSelect, toSelectCount, toSQL92Join, toTraditionalJoin, toUpdate, updateBlob, updateClob, validateBatchProcess, validateDBSpecificBatchProcess
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tableType

public String tableType
The MySQL table type to use when creating tables; defaults to innodb.


useClobs

public boolean useClobs
Whether to use clobs. Some older versions of MySQL do not handle clobs properly so we default to false here.


driverDeserializesBlobs

public boolean driverDeserializesBlobs
Whether the driver automatically deserializes blobs.


optimizeMultiTableDeletes

public boolean optimizeMultiTableDeletes
Whether to inline multi-table bulk-delete operations into MySQL's combined DELETE FROM foo, bar, baz syntax. Defaults to false, since this may fail in the presence of InnoDB tables with foreign keys.

See Also:
http://dev.mysql.com/doc/refman/5.0/en/delete.html
Constructor Detail

MySQLDictionary

public MySQLDictionary()
Method Detail

connectedConfiguration

public void connectedConfiguration(Connection conn)
                            throws SQLException
Description copied from class: DBDictionary
This method is called when the dictionary first sees any connection. It is used to initialize dictionary metadata if needed. If you override this method, be sure to call super.connectedConfiguration.

Overrides:
connectedConfiguration in class DBDictionary
Throws:
SQLException

getCreateTableSQL

public String[] getCreateTableSQL(Table table)
Description copied from class: DBDictionary
Return a series of SQL statements to create the given table, complete with columns. Indexes and constraints will be created separately.

Overrides:
getCreateTableSQL in class DBDictionary

getDropIndexSQL

public String[] getDropIndexSQL(Index index)
Description copied from class: DBDictionary
Return a series of SQL statements to drop the given index. Returns DROP INDEX <index name> by default.

Overrides:
getDropIndexSQL in class DBDictionary

getAddPrimaryKeySQL

public String[] getAddPrimaryKeySQL(PrimaryKey pk)
Description copied from class: DBDictionary
Return a series of SQL statements to add the given primary key to its table. Return an empty array if operation not supported. Returns ALTER TABLE <table name> ADD <pk cons sql > by default.

Overrides:
getAddPrimaryKeySQL in class DBDictionary

getForeignKeyConstraintSQL

protected String getForeignKeyConstraintSQL(ForeignKey fk)
Description copied from class: DBDictionary
Return the declaration SQL for the given foreign key, or null if it is not supported. This method is used from within DBDictionary.getCreateTableSQL(org.apache.openjpa.jdbc.schema.Table) and DBDictionary.getAddForeignKeySQL(org.apache.openjpa.jdbc.schema.ForeignKey). Returns CONSTRAINT <cons name> FOREIGN KEY (<col list>) REFERENCES <foreign table> (<col list>) [ON DELETE <action>] [ON UPDATE <action>] by default.

Overrides:
getForeignKeyConstraintSQL in class DBDictionary

getDeleteTableContentsSQL

public String[] getDeleteTableContentsSQL(Table[] tables)
Description copied from class: DBDictionary
Create SQL to delete the contents of the specified tables. The default implementation drops all non-deferred RESTRICT foreign key constraints involving the specified tables, issues DELETE statements against the tables, and then adds the dropped constraints back in. Databases with more optimal ways of deleting the contents of several tables should override this method.

Overrides:
getDeleteTableContentsSQL in class DBDictionary

appendSelectRange

protected void appendSelectRange(SQLBuffer buf,
                                 long start,
                                 long end,
                                 boolean subselect)
Description copied from class: DBDictionary
If this dictionary can select ranges, use this method to append the range SQL.

Overrides:
appendSelectRange in class DBDictionary

newColumn

protected Column newColumn(ResultSet colMeta)
                    throws SQLException
Description copied from class: DBDictionary
Create a new column from the information in the schema metadata.

Overrides:
newColumn in class DBDictionary
Throws:
SQLException

getBlobObject

public Object getBlobObject(ResultSet rs,
                            int column,
                            JDBCStore store)
                     throws SQLException
Description copied from class: DBDictionary
Convert the specified column of the SQL ResultSet to the proper java type.

Overrides:
getBlobObject in class DBDictionary
Throws:
SQLException

getPreferredType

public int getPreferredType(int type)
Description copied from class: DBDictionary
Return the preferred Types type for the given one. Returns the given type by default.

Overrides:
getPreferredType in class DBDictionary


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.