org.ujorm.orm.dialect
Class MySqlDialect

java.lang.Object
  extended by org.ujorm.orm.SqlDialect
      extended by org.ujorm.orm.dialect.MySqlDialect

public class MySqlDialect
extends SqlDialect

Dialect for the MySQL since release 5.0 for the InnoDB engine.
http://dev.mysql.com/


Field Summary
static int VARCHAR_MAX_LENGTH
          The Max length of VARCHAR database type
 
Fields inherited from class org.ujorm.orm.SqlDialect
COMMON_SEQ_TABLE_KEY, DEFAULT_SCHEMA_SYMBOL, ormHandler
 
Constructor Summary
MySqlDialect()
           
 
Method Summary
protected  String getColumnType(MetaColumn column)
          MySQL dialect uses a database type DATETIME (instead of the TIMESTAMP) for the java.util.Date.
protected  String getEngine(MetaTable table)
          Returns a MySQL enginge.
 String getJdbcDriver()
          Returns a JDBC driver class name.
 String getJdbcUrl()
          Returns a default JDBC URL
 boolean isCatalog()
          Does the database support a catalog? The feature supports: MySqlDialect and MSSqlDialect.
 Appendable printComment(MetaColumn column, Appendable out)
          Important note for MySQL: the change of column modifies all another column attributes so the comment update can revert some hand-made changes different from meta-model.
See the official MySQL documentation for more information.
 Appendable printComment(MetaTable table, Appendable out)
          Print a Comment on the table
 Appendable printDelete(CriterionDecoder decoder, Appendable out)
          Print an SQL DELETE statement.
 Appendable printNextSequence(String sequenceName, MetaTable table, Appendable out)
          Create a SQL script for the NEXT SEQUENCE from a native database sequencer
TIP: SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = $dbName AND TABLE_NAME = $tblName.
 Appendable printQuotedNameAlways(CharSequence name, Appendable sql)
          Prints quoted name (identifier) to SQL always.
 Appendable printSequenceTable(MetaDatabase db, Appendable out)
          Print SQL CREATE SEQUENCE.
 Appendable printTable(MetaTable table, Appendable out)
          Print a SQL script to create table
 Appendable printUpdate(List<MetaColumn> changedColumns, CriterionDecoder decoder, Appendable out)
          Print an SQL UPDATE statement.
protected  Appendable printWhere(CriterionDecoder decoder, TableWrapper[] tables, Appendable out)
          Print where condition for DELETE / UPDATE TODO: FIX THE IMPLEMENTATION - probably in the CriterionDecoder class
 
Methods inherited from class org.ujorm.orm.SqlDialect
createConnection, createJndiInitialContext, createSubQuery, escape, getAliasColumnName, getCriterionTemplate, getExtentedDialect, getKeywordSet, getNameProvider, getQuotedName, getSeqTableModel, isColumnLengthAllowed, isFilled, isMultiRowInsertSupported, printAlterTableAddColumn, printAlterTableColumn, printCall, printColumnAlias, printColumnDeclaration, printCommit, printCreateSchema, printCriterion, printCriterionValue, printDefaultConstraint, printDefaultSchema, printDefaultValue, printFKColumnsDeclaration, printForeignKey, printForeignKey, printFullTableName, printFullTableName, printIndex, printInsert, printInsert, printInsertBySelect, println, printLockForSelect, printOffset, printQuotedName, printSelect, printSelectOrder, printSelectTable, printSelectTableBase, printSelectView, printSequenceCurrentValue, printSequenceDeleteById, printSequenceInit, printSequenceInitWithValues, printSequenceNextValue, printSequenceTableName, printSetMaxSequence, printTableAliasDefinition, printTableColumns, releaseSavepoint, setHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VARCHAR_MAX_LENGTH

public static final int VARCHAR_MAX_LENGTH
The Max length of VARCHAR database type

See Also:
Constant Field Values
Constructor Detail

MySqlDialect

public MySqlDialect()
Method Detail

getJdbcUrl

public String getJdbcUrl()
Description copied from class: SqlDialect
Returns a default JDBC URL

Specified by:
getJdbcUrl in class SqlDialect

getJdbcDriver

public String getJdbcDriver()
Description copied from class: SqlDialect
Returns a JDBC driver class name.

Specified by:
getJdbcDriver in class SqlDialect

isCatalog

public boolean isCatalog()
Does the database support a catalog? The feature supports: MySqlDialect and MSSqlDialect.

Overrides:
isCatalog in class SqlDialect
Returns:
The default value is true.

printDelete

public Appendable printDelete(CriterionDecoder decoder,
                              Appendable out)
                       throws IOException
Print an SQL DELETE statement.

Overrides:
printDelete in class SqlDialect
Throws:
IOException

printUpdate

public Appendable printUpdate(List<MetaColumn> changedColumns,
                              CriterionDecoder decoder,
                              Appendable out)
                       throws IOException
Description copied from class: SqlDialect
Print an SQL UPDATE statement.

Overrides:
printUpdate in class SqlDialect
Throws:
IOException

printWhere

protected Appendable printWhere(CriterionDecoder decoder,
                                TableWrapper[] tables,
                                Appendable out)
                         throws IOException
Print where condition for DELETE / UPDATE TODO: FIX THE IMPLEMENTATION - probably in the CriterionDecoder class

Throws:
IOException

printSequenceTable

public Appendable printSequenceTable(MetaDatabase db,
                                     Appendable out)
                              throws IOException
Description copied from class: SqlDialect
Print SQL CREATE SEQUENCE. No JDBC parameters.

Overrides:
printSequenceTable in class SqlDialect
Throws:
IOException

printTable

public Appendable printTable(MetaTable table,
                             Appendable out)
                      throws IOException
Description copied from class: SqlDialect
Print a SQL script to create table

Overrides:
printTable in class SqlDialect
Throws:
IOException

getEngine

protected String getEngine(MetaTable table)
Returns a MySQL enginge.
The default value is " ENGINE = InnoDB".


getColumnType

protected String getColumnType(MetaColumn column)
MySQL dialect uses a database type DATETIME (instead of the TIMESTAMP) for the java.util.Date.

Overrides:
getColumnType in class SqlDialect

printComment

public Appendable printComment(MetaTable table,
                               Appendable out)
                        throws IOException
Print a Comment on the table

Overrides:
printComment in class SqlDialect
Throws:
IOException

printComment

public Appendable printComment(MetaColumn column,
                               Appendable out)
                        throws IOException
Important note for MySQL: the change of column modifies all another column attributes so the comment update can revert some hand-made changes different from meta-model.
See the official MySQL documentation for more information. The column comments can be suppresed by the overwritting the method with an empty body.

Overrides:
printComment in class SqlDialect
Throws:
IOException

printQuotedNameAlways

public Appendable printQuotedNameAlways(CharSequence name,
                                        Appendable sql)
                                 throws IOException
Prints quoted name (identifier) to SQL always. The default quated character is '"', however different SQL dialects must have got a different character-pairs.

Overrides:
printQuotedNameAlways in class SqlDialect
Parameters:
name - Name (identifier) for quoting
sql - Target SQL for printing new quoted name
Returns:
SQL with printed quoted name
Throws:
IOException

printNextSequence

public Appendable printNextSequence(String sequenceName,
                                    MetaTable table,
                                    Appendable out)
                             throws IOException
Create a SQL script for the NEXT SEQUENCE from a native database sequencer
TIP: SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = $dbName AND TABLE_NAME = $tblName.

Overrides:
printNextSequence in class SqlDialect
Throws:
IOException


Copyright 2013, Pavel Ponec