Class BaseDB

Object
com.liferay.portal.dao.db.BaseDB
All Implemented Interfaces:
com.liferay.portal.kernel.dao.db.DB
Direct Known Subclasses:
HypersonicDB, MySQLDB, PostgreSQLDB

public abstract class BaseDB extends Object implements com.liferay.portal.kernel.dao.db.DB
Author:
Alexander Chow, Ganesh Ram, Brian Wing Shun Chan, Daniel Kocsis
  • Field Details

  • Constructor Details

    • BaseDB

      protected BaseDB(com.liferay.portal.kernel.dao.db.DBType dbType, int majorVersion, int minorVersion)
  • Method Details

    • addIndexes

      public void addIndexes(Connection connection, List<com.liferay.portal.kernel.dao.db.IndexMetadata> indexMetadatas) throws IOException, SQLException
      Specified by:
      addIndexes in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      IOException
      SQLException
    • alterColumnName

      public void alterColumnName(Connection connection, String tableName, String oldColumnName, String newColumnDefinition) throws Exception
      Specified by:
      alterColumnName in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • alterColumnType

      public void alterColumnType(Connection connection, String tableName, String columnName, String newColumnType) throws Exception
      Specified by:
      alterColumnType in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • alterTableAddColumn

      public void alterTableAddColumn(Connection connection, String tableName, String columnName, String columnType) throws Exception
      Specified by:
      alterTableAddColumn in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • alterTableDropColumn

      public void alterTableDropColumn(Connection connection, String tableName, String columnName) throws Exception
      Specified by:
      alterTableDropColumn in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • buildSQL

      public abstract String buildSQL(String template) throws IOException, SQLException
      Specified by:
      buildSQL in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      IOException
      SQLException
    • copyTableRows

      public void copyTableRows(Connection connection, String sourceTableName, String targetTableName, Map<String,String> columnNamesMap, Map<String,String> defaultValuesMap) throws Exception
      Specified by:
      copyTableRows in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • copyTableStructure

      public void copyTableStructure(Connection connection, String tableName, String newTableName) throws Exception
      Specified by:
      copyTableStructure in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • dropIndexes

      public List<com.liferay.portal.kernel.dao.db.IndexMetadata> dropIndexes(Connection connection, String tableName, String columnName) throws IOException, SQLException
      Specified by:
      dropIndexes in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      IOException
      SQLException
    • getDBType

      public com.liferay.portal.kernel.dao.db.DBType getDBType()
      Specified by:
      getDBType in interface com.liferay.portal.kernel.dao.db.DB
    • getDefaultValue

      public String getDefaultValue(String columnDef)
      Specified by:
      getDefaultValue in interface com.liferay.portal.kernel.dao.db.DB
    • getIndexes

      public List<com.liferay.portal.kernel.dao.db.Index> getIndexes(Connection connection) throws SQLException
      Specified by:
      getIndexes in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      SQLException
    • getIndexMetadatas

      public List<com.liferay.portal.kernel.dao.db.IndexMetadata> getIndexMetadatas(Connection connection, String tableName, String columnName, boolean onlyUnique) throws SQLException
      Specified by:
      getIndexMetadatas in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      SQLException
    • getIndexResultSet

      public ResultSet getIndexResultSet(Connection connection, String tableName, boolean onlyUnique) throws SQLException
      Specified by:
      getIndexResultSet in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      SQLException
    • getMajorVersion

      public int getMajorVersion()
      Specified by:
      getMajorVersion in interface com.liferay.portal.kernel.dao.db.DB
    • getMinorVersion

      public int getMinorVersion()
      Specified by:
      getMinorVersion in interface com.liferay.portal.kernel.dao.db.DB
    • getPrimaryKeyColumnNames

      public String[] getPrimaryKeyColumnNames(Connection connection, String tableName) throws SQLException
      Specified by:
      getPrimaryKeyColumnNames in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      SQLException
    • getSQLType

      public Integer getSQLType(String templateType)
      Specified by:
      getSQLType in interface com.liferay.portal.kernel.dao.db.DB
    • getSQLTypeDecimalDigits

      public Integer getSQLTypeDecimalDigits(String templateType)
      Specified by:
      getSQLTypeDecimalDigits in interface com.liferay.portal.kernel.dao.db.DB
    • getSQLTypeSize

      public Integer getSQLTypeSize(String templateType)
      Specified by:
      getSQLTypeSize in interface com.liferay.portal.kernel.dao.db.DB
    • getTemplateBlob

      public String getTemplateBlob()
      Specified by:
      getTemplateBlob in interface com.liferay.portal.kernel.dao.db.DB
    • getTemplateFalse

      public String getTemplateFalse()
      Specified by:
      getTemplateFalse in interface com.liferay.portal.kernel.dao.db.DB
    • getTemplateTrue

      public String getTemplateTrue()
      Specified by:
      getTemplateTrue in interface com.liferay.portal.kernel.dao.db.DB
    • getVersionString

      public String getVersionString()
      Specified by:
      getVersionString in interface com.liferay.portal.kernel.dao.db.DB
    • isSupportsAlterColumnName

      public boolean isSupportsAlterColumnName()
      Specified by:
      isSupportsAlterColumnName in interface com.liferay.portal.kernel.dao.db.DB
    • isSupportsAlterColumnType

      public boolean isSupportsAlterColumnType()
      Specified by:
      isSupportsAlterColumnType in interface com.liferay.portal.kernel.dao.db.DB
    • isSupportsDBPartition

      public boolean isSupportsDBPartition()
      Specified by:
      isSupportsDBPartition in interface com.liferay.portal.kernel.dao.db.DB
    • isSupportsInlineDistinct

      public boolean isSupportsInlineDistinct()
      Specified by:
      isSupportsInlineDistinct in interface com.liferay.portal.kernel.dao.db.DB
    • isSupportsQueryingAfterException

      public boolean isSupportsQueryingAfterException()
      Specified by:
      isSupportsQueryingAfterException in interface com.liferay.portal.kernel.dao.db.DB
    • isSupportsScrollableResults

      public boolean isSupportsScrollableResults()
      Specified by:
      isSupportsScrollableResults in interface com.liferay.portal.kernel.dao.db.DB
    • isSupportsStringCaseSensitiveQuery

      public boolean isSupportsStringCaseSensitiveQuery()
      Specified by:
      isSupportsStringCaseSensitiveQuery in interface com.liferay.portal.kernel.dao.db.DB
    • isSupportsUpdateWithInnerJoin

      public boolean isSupportsUpdateWithInnerJoin()
      Specified by:
      isSupportsUpdateWithInnerJoin in interface com.liferay.portal.kernel.dao.db.DB
    • process

      public void process(com.liferay.petra.function.UnsafeConsumer<Long,Exception> unsafeConsumer) throws Exception
      Specified by:
      process in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • removePrimaryKey

      public void removePrimaryKey(Connection connection, String tableName) throws Exception
      Specified by:
      removePrimaryKey in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • renameTables

      public void renameTables(Connection connection, com.liferay.portal.kernel.util.ObjectValuePair<String,String>... tableNameObjectValuePairs) throws Exception
      Specified by:
      renameTables in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • runSQL

      public void runSQL(Connection connection, String sql) throws IOException, SQLException
      Specified by:
      runSQL in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      IOException
      SQLException
    • runSQL

      public void runSQL(Connection connection, String[] sqls) throws IOException, SQLException
      Specified by:
      runSQL in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      IOException
      SQLException
    • runSQL

      public void runSQL(String sql) throws IOException, SQLException
      Specified by:
      runSQL in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      IOException
      SQLException
    • runSQL

      public void runSQL(String[] sqls) throws IOException, SQLException
      Specified by:
      runSQL in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      IOException
      SQLException
    • runSQLTemplate

      public void runSQLTemplate(Connection connection, String template, boolean failOnError) throws IOException, NamingException, SQLException
      Specified by:
      runSQLTemplate in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      IOException
      NamingException
      SQLException
    • runSQLTemplate

      public void runSQLTemplate(String template, boolean failOnError) throws IOException, NamingException, SQLException
      Specified by:
      runSQLTemplate in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      IOException
      NamingException
      SQLException
    • setSupportsStringCaseSensitiveQuery

      public void setSupportsStringCaseSensitiveQuery(boolean supportsStringCaseSensitiveQuery)
      Specified by:
      setSupportsStringCaseSensitiveQuery in interface com.liferay.portal.kernel.dao.db.DB
    • syncTables

      public AutoCloseable syncTables(Connection connection, String sourceTableName, String targetTableName, Map<String,String> columnNamesMap, Map<String,String> defaultValuesMap) throws Exception
      Specified by:
      syncTables in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • updateIndexes

      public void updateIndexes(Connection connection, String tableName, String indexesSQL, boolean dropIndexes) throws Exception
      Specified by:
      updateIndexes in interface com.liferay.portal.kernel.dao.db.DB
      Throws:
      Exception
    • addPrimaryKey

      protected void addPrimaryKey(Connection connection, String tableName, String[] columnNames) throws IOException, SQLException
      Throws:
      IOException
      SQLException
    • buildColumnNameTokens

      protected String[] buildColumnNameTokens(String line)
    • buildColumnTypeTokens

      protected String[] buildColumnTypeTokens(String line)
    • buildTableNameTokens

      protected String[] buildTableNameTokens(String line)
    • createSyncDeleteTrigger

      protected void createSyncDeleteTrigger(Connection connection, String sourceTableName, String targetTableName, String triggerName, String[] sourcePrimaryKeyColumnNames, String[] targetPrimaryKeyColumnNames) throws Exception
      Throws:
      Exception
    • createSyncInsertTrigger

      protected void createSyncInsertTrigger(Connection connection, String sourceTableName, String targetTableName, String triggerName, String[] sourceColumnNames, String[] targetColumnNames, String[] sourcePrimaryKeyColumnNames, String[] targetPrimaryKeyColumnNames, Map<String,String> defaultValuesMap) throws Exception
      Throws:
      Exception
    • createSyncUpdateTrigger

      protected void createSyncUpdateTrigger(Connection connection, String sourceTableName, String targetTableName, String triggerName, String[] sourceColumnNames, String[] targetColumnNames, String[] sourcePrimaryKeyColumnNames, String[] targetPrimaryKeyColumnNames, Map<String,String> defaultValuesMap) throws Exception
      Throws:
      Exception
    • doRenameTables

      protected void doRenameTables(Connection connection, com.liferay.portal.kernel.util.ObjectValuePair<String,String>... tableNameObjectValuePairs) throws Exception
      Throws:
      Exception
    • dropIndexes

      protected Set<String> dropIndexes(Connection connection, String indexesSQL, List<com.liferay.portal.kernel.dao.db.Index> indexes) throws IOException, SQLException
      Throws:
      IOException
      SQLException
    • dropTrigger

      protected void dropTrigger(Connection connection, String tableName, String triggerName) throws Exception
      Throws:
      Exception
    • getCopyTableStructureSQL

      protected String getCopyTableStructureSQL(String tableName, String newTableName)
    • getIndexColumnName

      protected String getIndexColumnName(String indexColumnName)
    • getRenameTableSQL

      protected String getRenameTableSQL(String oldTableName, String newTableName)
    • getSQLTypes

      protected abstract int[] getSQLTypes()
    • getSQLVarcharSizes

      protected Map<String,Integer> getSQLVarcharSizes()
    • getTemplate

      protected abstract String[] getTemplate()
    • isSupportsDDLRollback

      protected boolean isSupportsDDLRollback()
    • isSupportsDuplicatedIndexName

      protected boolean isSupportsDuplicatedIndexName()
    • limitColumnLength

      protected String limitColumnLength(String column, int length)
    • replaceTemplate

      protected String replaceTemplate(String template)
    • reword

      protected abstract String reword(String data) throws IOException, SQLException
      Throws:
      IOException
      SQLException