com.dotmarketing.startup
Class AbstractJDBCStartupTask

java.lang.Object
  extended by com.dotmarketing.startup.AbstractJDBCStartupTask
All Implemented Interfaces:
StartupTask
Direct Known Subclasses:
Task00760AddContentletStructureInodeIndex, Task00765AddUserForeignKeys, Task00766AddFieldVariableTable, Task00767FieldVariableValueTypeChange, Task00769UpdateTagDataModel, Task00775DropUnusedTables, Task00780UUIDTypeChange, Task00805AddRenameFolderProcedure, Task00825UpdateLoadRecordsToIndex, Task00835CreateIndiciesTables, Task00855FixRenameFolder, Task00905FixAddFolderAfterDelete, Task00910AddEscalationFields, Task00922FixdotfolderpathMSSQL, Task00925UserIdTypeChange, Task00930AddIdentifierIndex, Task01000LinkChequerTable, Task01005TemplateThemeField, Task01015AddPublishExpireDateToIdentifier, Task01030AddSiteSearchAuditTable, Task01035FixTriggerVarLength

public abstract class AbstractJDBCStartupTask
extends java.lang.Object
implements StartupTask

Derived classes should avoid use of transactions. MSSQL might have problems to handle a mix of DDL+DML because of the snapshot insolation setting.
The cleaner way to avoid it is to set autocommit on the threadlocal connection DbConnectionFactory.getConnection().setAutoCommit(true). So DotConnect and HibernateUtil will not have problems with MSSQL.

Since:
1.6.5a
Author:
Jason Tesser, Andres Olarte

Nested Class Summary
 class AbstractJDBCStartupTask.ForeignKey
           
 class AbstractJDBCStartupTask.Index
           
 class AbstractJDBCStartupTask.PrimaryKey
           
 
Field Summary
protected  boolean runInSingleTransaction
          By default statements should run in a single transaction.
 
Constructor Summary
AbstractJDBCStartupTask()
           
 
Method Summary
protected  void createConstraint(java.sql.Connection conn, AbstractJDBCStartupTask.ForeignKey key)
           
protected  void createIndex(java.sql.Connection conn, AbstractJDBCStartupTask.Index index)
           
protected  void createPrimaryKey(java.sql.Connection conn, AbstractJDBCStartupTask.PrimaryKey key)
           
protected  void executeDropConstraint(java.sql.Connection conn, java.lang.String tableName, java.lang.String constraintName)
           
protected  void executeDropForeignKeyMySql(java.sql.Connection conn, java.lang.String tableName, java.lang.String constraintName)
           
protected  void executeDropIndex(java.sql.Connection conn, java.lang.String tableName, java.lang.String constraintName)
           
 void executeUpgrade()
          The instructions to execute.
protected  java.lang.String getColumnList(java.util.List<java.lang.String> columns)
           
protected  java.util.List<AbstractJDBCStartupTask.ForeignKey> getForeingKeys(java.sql.Connection conn, java.util.List<java.lang.String> tables, boolean executeDrop)
           
protected  java.util.List<AbstractJDBCStartupTask.Index> getIndexes(java.sql.Connection conn, java.util.List<java.lang.String> tables, boolean executeDrop)
           
abstract  java.lang.String getMSSQLScript()
          The SQL for MSSQL
abstract  java.lang.String getMySQLScript()
          The SQL MySQL
abstract  java.lang.String getOracleScript()
          The SQL for Oracle
abstract  java.lang.String getPostgresScript()
          The SQL for Postgres
protected  java.util.List<AbstractJDBCStartupTask.PrimaryKey> getPrimaryKey(java.sql.Connection conn, java.util.List<java.lang.String> tablesWithKeys, boolean drop)
           
protected abstract  java.util.List<java.lang.String> getTablesToDropConstraints()
          This is a list of tables which will get the constraints dropped prior to the task executing and then get recreated afer the execution of the DB Specific SQL
protected  java.util.List<java.lang.String> getTablesToDropPrimaryKeys()
           
protected  void setRebuildForeignKeys(java.lang.Boolean rebuildForeignKeys)
           
protected  void setRebuildIndices(java.lang.Boolean rebuildIndices)
           
protected  void setRebuildPrimaryKeys(java.lang.Boolean rebuildPrimaryKeys)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.dotmarketing.startup.StartupTask
forceRun
 

Field Detail

runInSingleTransaction

protected boolean runInSingleTransaction
By default statements should run in a single transaction. If you set to false every statement of the Script will be tokenized and executed within a separate transactions.

Constructor Detail

AbstractJDBCStartupTask

public AbstractJDBCStartupTask()
Method Detail

executeUpgrade

public void executeUpgrade()
                    throws DotDataException,
                           DotRuntimeException
Description copied from interface: StartupTask
The instructions to execute.

Specified by:
executeUpgrade in interface StartupTask
Throws:
DotDataException
DotRuntimeException

getTablesToDropPrimaryKeys

protected java.util.List<java.lang.String> getTablesToDropPrimaryKeys()

executeDropIndex

protected void executeDropIndex(java.sql.Connection conn,
                                java.lang.String tableName,
                                java.lang.String constraintName)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

executeDropConstraint

protected void executeDropConstraint(java.sql.Connection conn,
                                     java.lang.String tableName,
                                     java.lang.String constraintName)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

executeDropForeignKeyMySql

protected void executeDropForeignKeyMySql(java.sql.Connection conn,
                                          java.lang.String tableName,
                                          java.lang.String constraintName)
                                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getColumnList

protected java.lang.String getColumnList(java.util.List<java.lang.String> columns)

createPrimaryKey

protected void createPrimaryKey(java.sql.Connection conn,
                                AbstractJDBCStartupTask.PrimaryKey key)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

createIndex

protected void createIndex(java.sql.Connection conn,
                           AbstractJDBCStartupTask.Index index)
                    throws java.sql.SQLException
Throws:
java.sql.SQLException

getForeingKeys

protected java.util.List<AbstractJDBCStartupTask.ForeignKey> getForeingKeys(java.sql.Connection conn,
                                                                            java.util.List<java.lang.String> tables,
                                                                            boolean executeDrop)

getIndexes

protected java.util.List<AbstractJDBCStartupTask.Index> getIndexes(java.sql.Connection conn,
                                                                   java.util.List<java.lang.String> tables,
                                                                   boolean executeDrop)

getPrimaryKey

protected java.util.List<AbstractJDBCStartupTask.PrimaryKey> getPrimaryKey(java.sql.Connection conn,
                                                                           java.util.List<java.lang.String> tablesWithKeys,
                                                                           boolean drop)

createConstraint

protected void createConstraint(java.sql.Connection conn,
                                AbstractJDBCStartupTask.ForeignKey key)
                         throws java.sql.SQLException
Throws:
java.sql.SQLException

setRebuildPrimaryKeys

protected void setRebuildPrimaryKeys(java.lang.Boolean rebuildPrimaryKeys)

setRebuildIndices

protected void setRebuildIndices(java.lang.Boolean rebuildIndices)

setRebuildForeignKeys

protected void setRebuildForeignKeys(java.lang.Boolean rebuildForeignKeys)

getPostgresScript

public abstract java.lang.String getPostgresScript()
The SQL for Postgres

Returns:

getMySQLScript

public abstract java.lang.String getMySQLScript()
The SQL MySQL

Returns:

getOracleScript

public abstract java.lang.String getOracleScript()
The SQL for Oracle

Returns:

getMSSQLScript

public abstract java.lang.String getMSSQLScript()
The SQL for MSSQL

Returns:

getTablesToDropConstraints

protected abstract java.util.List<java.lang.String> getTablesToDropConstraints()
This is a list of tables which will get the constraints dropped prior to the task executing and then get recreated afer the execution of the DB Specific SQL

Returns:
Throws:
DotDataException


Copyright © 2013 dotCMS Inc. All Rights Reserved.