org.apache.ddlutils.platform.sybase
Class SybaseBuilder

java.lang.Object
  extended byorg.apache.ddlutils.platform.SqlBuilder
      extended byorg.apache.ddlutils.platform.sybase.SybaseBuilder

public class SybaseBuilder
extends SqlBuilder

The SQL Builder for Sybase.

Version:
$Revision: 378736 $
Author:
James Strachan, Thomas Dudziak

Field Summary
 
Fields inherited from class org.apache.ddlutils.platform.SqlBuilder
_log, SIZE_PLACEHOLDER
 
Constructor Summary
SybaseBuilder(PlatformInfo info)
          Creates a new builder instance.
 
Method Summary
protected  void alterTable(Database currentModel, Table currentTable, Database desiredModel, Table desiredTable, boolean doDrops, boolean modifyColumns)
          Alters the given currently existing table object to match the given desired table object.
 void createTable(Database database, Table table, Map parameters)
          Outputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).
 void dropExternalForeignKeys(Table table)
          Creates external foreignkey drop statements.
 void dropTable(Table table)
          Outputs the DDL to drop the table.
 String getDeleteSql(Table table, Map pkValues, boolean genPlaceholders)
          Creates the SQL for deleting an object from the specified table. If values are given then a concrete delete statement is created, otherwise an delete statement usable in a prepared statement is build.
 String getInsertSql(Table table, Map columnValues, boolean genPlaceholders)
          Creates the SQL for inserting an object into the specified table. If values are given then a concrete insert statement is created, otherwise an insert statement usable in a prepared statement is build.
 String getUpdateSql(Table table, Map columnValues, boolean genPlaceholders)
          Creates the SQL for updating an object in the specified table. If values are given then a concrete update statement is created, otherwise an update statement usable in a prepared statement is build.
protected  void writeExternalForeignKeyDropStmt(Table table, ForeignKey foreignKey)
          Generates the statement to drop a foreignkey constraint from the database using an alter table statement.
 
Methods inherited from class org.apache.ddlutils.platform.SqlBuilder
addEscapedCharSequence, alterDatabase, alterDatabase, alterDatabase, columnsDiffer, createExternalForeignKeys, createExternalForeignKeys, createTable, createTables, createTables, createTables, dropTables, escapeStringValue, getColumnName, getConstraintName, getDefaultValueHelper, getDelimitedIdentifier, getForeignKeyName, getIndent, getIndexName, getNativeDefaultValue, getNativeType, getPlatformInfo, getSelectLastInsertId, getSqlType, getTableName, getValueAsString, getValueLocale, getWriter, print, printComment, printEndOfStatement, printIdentifier, printIndent, println, println, printlnIdentifier, printStartOfEmbeddedStatement, setIndent, setValueLocale, setWriter, shortenName, shouldGeneratePrimaryKeys, writeColumn, writeColumnAlterStmt, writeColumnAutoIncrementStmt, writeColumnDefaultValue, writeColumnDropStmt, writeColumnNotNullableStmt, writeColumnNullableStmt, writeColumns, writeEmbeddedForeignKeysStmt, writeEmbeddedIndexCreateStmt, writeEmbeddedIndicesStmt, writeEmbeddedPrimaryKeysStmt, writeExternalForeignKeyCreateStmt, writeExternalIndexCreateStmt, writeExternalIndexDropStmt, writeExternalIndicesCreateStmt, writeExternalPrimaryKeysCreateStmt, writeForeignReferences, writeLocalReferences, writePrimaryKeyStmt, writeTableAlterStmt, writeTableComment, writeTableCreationStmtEnding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SybaseBuilder

public SybaseBuilder(PlatformInfo info)
Creates a new builder instance.

Parameters:
info - The platform info
Method Detail

createTable

public void createTable(Database database,
                        Table table,
                        Map parameters)
                 throws IOException
Outputs the DDL to create the table along with any non-external constraints as well as with external primary keys and indices (but not foreign keys).

Overrides:
createTable in class SqlBuilder
Parameters:
database - The database model
table - The table
parameters - Additional platform-specific parameters for the table creation
Throws:
IOException

alterTable

protected void alterTable(Database currentModel,
                          Table currentTable,
                          Database desiredModel,
                          Table desiredTable,
                          boolean doDrops,
                          boolean modifyColumns)
                   throws IOException
Alters the given currently existing table object to match the given desired table object.

Overrides:
alterTable in class SqlBuilder
Parameters:
currentModel - The current model
currentTable - The current table definition
desiredModel - The desired model
desiredTable - The desired table definition
doDrops - Whether columns and indexes should be dropped if not in the new schema
modifyColumns - Whether columns should be altered for datatype, size as required
Throws:
IOException

dropTable

public void dropTable(Table table)
               throws IOException
Outputs the DDL to drop the table.

Overrides:
dropTable in class SqlBuilder
Parameters:
table - The table to drop
Throws:
IOException

writeExternalForeignKeyDropStmt

protected void writeExternalForeignKeyDropStmt(Table table,
                                               ForeignKey foreignKey)
                                        throws IOException
Generates the statement to drop a foreignkey constraint from the database using an alter table statement.

Overrides:
writeExternalForeignKeyDropStmt in class SqlBuilder
Parameters:
table - The table
foreignKey - The foreign key
Throws:
IOException

dropExternalForeignKeys

public void dropExternalForeignKeys(Table table)
                             throws IOException
Creates external foreignkey drop statements.

Overrides:
dropExternalForeignKeys in class SqlBuilder
Parameters:
table - The table
Throws:
IOException

getDeleteSql

public String getDeleteSql(Table table,
                           Map pkValues,
                           boolean genPlaceholders)
Creates the SQL for deleting an object from the specified table. If values are given then a concrete delete statement is created, otherwise an delete statement usable in a prepared statement is build.

Overrides:
getDeleteSql in class SqlBuilder
Parameters:
table - The table
pkValues - The primary key values indexed by the column names, can be empty
genPlaceholders - Whether to generate value placeholders for a prepared statement
Returns:
The delete sql

getInsertSql

public String getInsertSql(Table table,
                           Map columnValues,
                           boolean genPlaceholders)
Creates the SQL for inserting an object into the specified table. If values are given then a concrete insert statement is created, otherwise an insert statement usable in a prepared statement is build.

Overrides:
getInsertSql in class SqlBuilder
Parameters:
table - The table
columnValues - The columns values indexed by the column names
genPlaceholders - Whether to generate value placeholders for a prepared statement
Returns:
The insertion sql

getUpdateSql

public String getUpdateSql(Table table,
                           Map columnValues,
                           boolean genPlaceholders)
Creates the SQL for updating an object in the specified table. If values are given then a concrete update statement is created, otherwise an update statement usable in a prepared statement is build.

Overrides:
getUpdateSql in class SqlBuilder
Parameters:
table - The table
columnValues - Contains the values for the columns to update, and should also contain the primary key values to identify the object to update in case genPlaceholders is false
genPlaceholders - Whether to generate value placeholders for a prepared statement (both for the pk values and the object values)
Returns:
The update sql


Copyright © 2005 Apache Software Foundation. All Rights Reserved.