ca.sqlpower.architect.ddl
Class MySqlDDLGenerator

java.lang.Object
  extended by ca.sqlpower.architect.ddl.GenericDDLGenerator
      extended by ca.sqlpower.architect.ddl.MySqlDDLGenerator
All Implemented Interfaces:
DDLGenerator

public class MySqlDDLGenerator
extends GenericDDLGenerator


Field Summary
static java.lang.String GENERATOR_VERSION
           
 
Fields inherited from class ca.sqlpower.architect.ddl.GenericDDLGenerator
allowConnection, con, EOL, profileFunctionMap, targetCatalog, targetSchema, topLevelNames, typeMap, warnings
 
Constructor Summary
MySqlDDLGenerator()
           
 
Method Summary
 void addIndex(SQLIndex index)
          Adds a DDL statement to this generator that will create the given index.
protected  void addPrimaryKeysToCreateTable(SQLTable t)
           
 java.lang.String columnType(SQLColumn c)
          Adds support for the MySQL auto_increment feature.
protected  void createTypeMap()
          Creates and populates typeMap using DatabaseMetaData.
 void dropRelationship(SQLRelationship r)
          Appends the DDL statement for dropping the given FK relationship in this DDL Generator's target schema/catalog.
 java.lang.String getCatalogTerm()
          The name that the target database gives to the JDBC idea of "catalog." For Oracle, this would be null (no catalogs) and for SQL Server it would be "Database".
 java.lang.String getDeferrabilityClause(SQLRelationship r)
          Returns the correct syntax for setting the deferrability of a foreign key relationship on this DDL Generator's target platform.
 java.lang.String getDeleteActionClause(SQLRelationship r)
          Returns the ON DELETE clause for the given relationship, with no extra whitespace or newline characters around it.
 java.lang.String getName()
          Returns the name of this DDL Generator, which should be a human-readable string with the vendor and/or product name (and version if the generator doesn't work with all versions) of the database platform this generator targets.
 java.lang.String getSchemaTerm()
          The name that the target database gives to the JDBC idea of "schema." For Oracle, this would be "Schema" and for SQL Server it would be "Owner".
 java.lang.String getUpdateActionClause(SQLRelationship r)
          Returns the ON UPDATE clause for the given relationship, with no extra whitespace or newline characters around it.
 boolean isReservedWord(java.lang.String word)
          Subroutine for toIdentifier().
 void modifyColumn(SQLColumn c)
          Appends the DDL statement for modifying the given column's datatype and nullability in its parent table in this DDL Generator's target schema/catalog.
 boolean supportsDeferrabilityPolicy(SQLRelationship r)
          Returns true if the platform supports the deferrability policy of the given relationship, false otherwise.
 boolean supportsDeleteAction(SQLRelationship r)
          Returns true if this DDL generator supports the given relationship's delete action.
 boolean supportsRollback()
          The generic DDL generator claims to support rollback operation, so specific platforms that don't support it should override this method.
 boolean supportsUpdateAction(SQLRelationship r)
          Returns true if this DDL generator supports the given relationship's update action.
 java.lang.String toIdentifier(java.lang.String name)
          Converts space to underscore in name and returns the possibly-modified string.
protected  void writePrimaryKey(SQLTable t)
           
 
Methods inherited from class ca.sqlpower.architect.ddl.GenericDDLGenerator
addColumn, addPrimaryKey, addRelationship, addTable, columnDefinition, columnNullability, createPhysicalName, createSeqPhysicalName, dropColumn, dropPrimaryKey, dropTable, endStatement, failsafeGetTypeDescriptor, generateDDLScript, generateDDLStatements, getAllowConnection, getColumnDataTypeName, getCon, getDdlStatements, getDefaultType, getProfileFunctionMap, getStatementTerminator, getTargetCatalog, getTargetSchema, getTypeMap, getWarnings, makeDropForeignKeySQL, makeDropTableSQL, print, println, setAllowConnection, setCon, setProfileFunctionMap, setTargetCatalog, setTargetSchema, setTypeMap, toQualifiedName, toQualifiedName, toQualifiedName, writeCreateDB, writeDDLTransactionBegin, writeDDLTransactionEnd, writeExportedRelationships, writeHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENERATOR_VERSION

public static final java.lang.String GENERATOR_VERSION
See Also:
Constant Field Values
Constructor Detail

MySqlDDLGenerator

public MySqlDDLGenerator()
                  throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

getName

public java.lang.String getName()
Description copied from interface: DDLGenerator
Returns the name of this DDL Generator, which should be a human-readable string with the vendor and/or product name (and version if the generator doesn't work with all versions) of the database platform this generator targets.

Specified by:
getName in interface DDLGenerator
Overrides:
getName in class GenericDDLGenerator

createTypeMap

protected void createTypeMap()
                      throws java.sql.SQLException
Description copied from class: GenericDDLGenerator
Creates and populates typeMap using DatabaseMetaData. Subclasses for specific DB platforms will be able to override this implementation with one that uses a static, pre-defined type map.

Overrides:
createTypeMap in class GenericDDLGenerator
Throws:
java.sql.SQLException

toIdentifier

public java.lang.String toIdentifier(java.lang.String name)
Description copied from class: GenericDDLGenerator
Converts space to underscore in name and returns the possibly-modified string. This will not be completely sufficient because it leaves ".", "%", and lots of other non-alphanumeric characters alone. Subclasses might choose to quote and leave everything alone, or whatever.

Specified by:
toIdentifier in interface DDLGenerator
Overrides:
toIdentifier in class GenericDDLGenerator

isReservedWord

public boolean isReservedWord(java.lang.String word)
Subroutine for toIdentifier(). Probably a generally useful feature that we should pull up to the GenericDDLGenerator.

Specified by:
isReservedWord in interface DDLGenerator
Overrides:
isReservedWord in class GenericDDLGenerator
Returns:

getCatalogTerm

public java.lang.String getCatalogTerm()
Description copied from class: GenericDDLGenerator
The name that the target database gives to the JDBC idea of "catalog." For Oracle, this would be null (no catalogs) and for SQL Server it would be "Database".

Specified by:
getCatalogTerm in interface DDLGenerator
Overrides:
getCatalogTerm in class GenericDDLGenerator

getSchemaTerm

public java.lang.String getSchemaTerm()
Description copied from class: GenericDDLGenerator
The name that the target database gives to the JDBC idea of "schema." For Oracle, this would be "Schema" and for SQL Server it would be "Owner".

Specified by:
getSchemaTerm in interface DDLGenerator
Overrides:
getSchemaTerm in class GenericDDLGenerator

addPrimaryKeysToCreateTable

protected void addPrimaryKeysToCreateTable(SQLTable t)
                                    throws ArchitectException
Overrides:
addPrimaryKeysToCreateTable in class GenericDDLGenerator
Throws:
ArchitectException

dropRelationship

public void dropRelationship(SQLRelationship r)
Description copied from interface: DDLGenerator
Appends the DDL statement for dropping the given FK relationship in this DDL Generator's target schema/catalog.

Specified by:
dropRelationship in interface DDLGenerator
Overrides:
dropRelationship in class GenericDDLGenerator

writePrimaryKey

protected void writePrimaryKey(SQLTable t)
                        throws ArchitectException
Overrides:
writePrimaryKey in class GenericDDLGenerator
Throws:
ArchitectException

columnType

public java.lang.String columnType(SQLColumn c)
Adds support for the MySQL auto_increment feature.

Specified by:
columnType in interface DDLGenerator
Overrides:
columnType in class GenericDDLGenerator
Returns:

addIndex

public void addIndex(SQLIndex index)
              throws ArchitectException
Description copied from class: GenericDDLGenerator
Adds a DDL statement to this generator that will create the given index.

Specified by:
addIndex in interface DDLGenerator
Overrides:
addIndex in class GenericDDLGenerator
Parameters:
index - The specification of the index to create. Note, if the index type is STATISTIC, no DDL will be generated because STATISTIC indices are just artificial JDBC constructs to describe table statistics (you can't create or drop them).
Throws:
ArchitectException

getDeferrabilityClause

public java.lang.String getDeferrabilityClause(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns the correct syntax for setting the deferrability of a foreign key relationship on this DDL Generator's target platform. Throws an UnsupportedOperationException if the platform does not support the given relationship's deferrability policy.

Overrides:
getDeferrabilityClause in class GenericDDLGenerator
Parameters:
r - The relationship the deferrability clause is for
Returns:
The SQL clause for declaring the deferrability policy in r.

supportsDeferrabilityPolicy

public boolean supportsDeferrabilityPolicy(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns true if the platform supports the deferrability policy of the given relationship, false otherwise. This generic method assumes support for all deferrability policies.

Overrides:
supportsDeferrabilityPolicy in class GenericDDLGenerator
Returns:
Whether the chosen platform supports the deferrability.

supportsDeleteAction

public boolean supportsDeleteAction(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns true if this DDL generator supports the given relationship's delete action. The generic DDL generator claims to support all delete actions, so specific platforms that don't support all delete actions should override this method.

Overrides:
supportsDeleteAction in class GenericDDLGenerator

getDeleteActionClause

public java.lang.String getDeleteActionClause(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns the ON DELETE clause for the given relationship, with no extra whitespace or newline characters around it.

If you are overriding this method for a platform-specific DDL generator and you need this clause to be empty, return the empty string--not null.

Overrides:
getDeleteActionClause in class GenericDDLGenerator
Parameters:
r - The relationship whose delete action clause to generate
Returns:
The delete action clause

supportsUpdateAction

public boolean supportsUpdateAction(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns true if this DDL generator supports the given relationship's update action. The generic DDL generator claims to support all update actions, so specific platforms that don't support all update actions should override this method.

Overrides:
supportsUpdateAction in class GenericDDLGenerator

getUpdateActionClause

public java.lang.String getUpdateActionClause(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns the ON UPDATE clause for the given relationship, with no extra whitespace or newline characters around it.

If you are overriding this method for a platform-specific DDL generator and you need this clause to be empty, return the empty string--not null.

Overrides:
getUpdateActionClause in class GenericDDLGenerator
Parameters:
r - The relationship whose update action clause to generate
Returns:
The update action clause

modifyColumn

public void modifyColumn(SQLColumn c)
Description copied from interface: DDLGenerator
Appends the DDL statement for modifying the given column's datatype and nullability in its parent table in this DDL Generator's target schema/catalog.

Specified by:
modifyColumn in interface DDLGenerator
Overrides:
modifyColumn in class GenericDDLGenerator
Parameters:
c - The column to create a MODIFY or ALTER COLUMN statement for.

supportsRollback

public boolean supportsRollback()
Description copied from class: GenericDDLGenerator
The generic DDL generator claims to support rollback operation, so specific platforms that don't support it should override this method.

Specified by:
supportsRollback in interface DDLGenerator
Overrides:
supportsRollback in class GenericDDLGenerator


Copyright © 2003-2007 SQL Power Group Inc. www.sqlpower.ca