public abstract class BaseDB
extends Object
implements com.liferay.portal.kernel.dao.db.DB
Modifier and Type | Field and Description |
---|---|
protected static String |
ALTER_COLUMN_NAME |
protected static String |
ALTER_COLUMN_TYPE |
protected static String |
ALTER_TABLE_NAME |
protected static Pattern |
columnTypePattern |
protected static String |
CREATE_TABLE |
protected static String |
DROP_INDEX |
protected static String |
DROP_PRIMARY_KEY |
protected static String[] |
RENAME_TABLE_TEMPLATE |
protected static String[] |
REWORD_TEMPLATE |
protected static int[] |
SQL_VARCHAR_TYPES |
protected static String[] |
TEMPLATE |
Modifier | Constructor and Description |
---|---|
protected |
BaseDB(com.liferay.portal.kernel.dao.db.DBType dbType,
int majorVersion,
int minorVersion) |
Modifier and Type | Method and Description |
---|---|
void |
addIndexes(Connection connection,
List<com.liferay.portal.kernel.dao.db.IndexMetadata> indexMetadatas) |
protected void |
addPrimaryKey(Connection connection,
String tableName,
String[] columnNames) |
void |
alterColumnName(Connection connection,
String tableName,
String oldColumnName,
String newColumnDefinition) |
void |
alterColumnType(Connection connection,
String tableName,
String columnName,
String newColumnType) |
void |
alterTableAddColumn(Connection connection,
String tableName,
String columnName,
String columnType) |
void |
alterTableDropColumn(Connection connection,
String tableName,
String columnName) |
protected String[] |
buildColumnNameTokens(String line) |
protected String[] |
buildColumnTypeTokens(String line) |
abstract String |
buildSQL(String template) |
protected String[] |
buildTableNameTokens(String line) |
void |
copyTableRows(Connection connection,
String sourceTableName,
String targetTableName,
Map<String,String> columnNamesMap,
Map<String,String> defaultValuesMap) |
void |
copyTableStructure(Connection connection,
String tableName,
String newTableName) |
protected void |
createSyncDeleteTrigger(Connection connection,
String sourceTableName,
String targetTableName,
String triggerName,
String[] sourcePrimaryKeyColumnNames,
String[] targetPrimaryKeyColumnNames) |
protected void |
createSyncInsertTrigger(Connection connection,
String sourceTableName,
String targetTableName,
String triggerName,
String[] sourceColumnNames,
String[] targetColumnNames,
String[] sourcePrimaryKeyColumnNames,
String[] targetPrimaryKeyColumnNames,
Map<String,String> defaultValuesMap) |
protected void |
createSyncUpdateTrigger(Connection connection,
String sourceTableName,
String targetTableName,
String triggerName,
String[] sourceColumnNames,
String[] targetColumnNames,
String[] sourcePrimaryKeyColumnNames,
String[] targetPrimaryKeyColumnNames,
Map<String,String> defaultValuesMap) |
protected void |
doRenameTables(Connection connection,
com.liferay.portal.kernel.util.ObjectValuePair<String,String>... tableNameObjectValuePairs) |
protected Set<String> |
dropIndexes(Connection connection,
String indexesSQL,
List<com.liferay.portal.kernel.dao.db.Index> indexes) |
List<com.liferay.portal.kernel.dao.db.IndexMetadata> |
dropIndexes(Connection connection,
String tableName,
String columnName) |
protected void |
dropTrigger(Connection connection,
String tableName,
String triggerName) |
protected String |
getCopyTableStructureSQL(String tableName,
String newTableName) |
com.liferay.portal.kernel.dao.db.DBType |
getDBType() |
String |
getDefaultValue(String columnDef) |
List<com.liferay.portal.kernel.dao.db.Index> |
getIndexes(Connection connection) |
protected List<com.liferay.portal.kernel.dao.db.IndexMetadata> |
getIndexes(Connection connection,
String tableName,
String columnName,
boolean onlyUnique) |
ResultSet |
getIndexResultSet(Connection connection,
String tableName,
boolean onlyUnique) |
int |
getMajorVersion() |
int |
getMinorVersion() |
String[] |
getPrimaryKeyColumnNames(Connection connection,
String tableName) |
protected String |
getRenameTableSQL(String oldTableName,
String newTableName) |
Integer |
getSQLType(String templateType) |
Integer |
getSQLTypeDecimalDigits(String templateType) |
protected abstract int[] |
getSQLTypes() |
Integer |
getSQLTypeSize(String templateType) |
protected Map<String,Integer> |
getSQLVarcharSizes() |
protected abstract String[] |
getTemplate() |
String |
getTemplateBlob() |
String |
getTemplateFalse() |
String |
getTemplateTrue() |
String |
getVersionString() |
boolean |
isSupportsAlterColumnName() |
boolean |
isSupportsAlterColumnType() |
boolean |
isSupportsDBPartition() |
protected boolean |
isSupportsDDLRollback() |
protected boolean |
isSupportsDuplicatedIndexName() |
boolean |
isSupportsInlineDistinct() |
boolean |
isSupportsQueryingAfterException() |
boolean |
isSupportsScrollableResults() |
boolean |
isSupportsStringCaseSensitiveQuery() |
boolean |
isSupportsUpdateWithInnerJoin() |
protected String |
limitColumnLength(String column,
int length) |
void |
process(com.liferay.petra.function.UnsafeConsumer<Long,Exception> unsafeConsumer) |
void |
removePrimaryKey(Connection connection,
String tableName) |
void |
renameTables(Connection connection,
com.liferay.portal.kernel.util.ObjectValuePair<String,String>... tableNameObjectValuePairs) |
protected String |
replaceTemplate(String template) |
protected abstract String |
reword(String data) |
void |
runSQL(Connection connection,
String sql) |
void |
runSQL(Connection connection,
String[] sqls) |
void |
runSQL(String sql) |
void |
runSQL(String[] sqls) |
void |
runSQLTemplateString(Connection connection,
String template,
boolean failOnError) |
void |
runSQLTemplateString(String template,
boolean failOnError) |
void |
setSupportsStringCaseSensitiveQuery(boolean supportsStringCaseSensitiveQuery) |
AutoCloseable |
syncTables(Connection connection,
String sourceTableName,
String targetTableName,
Map<String,String> columnNamesMap,
Map<String,String> defaultValuesMap) |
void |
updateIndexes(Connection connection,
String tableName,
String indexesSQL,
boolean dropIndexes) |
protected static final String ALTER_COLUMN_NAME
protected static final String ALTER_COLUMN_TYPE
protected static final String ALTER_TABLE_NAME
protected static final String CREATE_TABLE
protected static final String DROP_INDEX
protected static final String DROP_PRIMARY_KEY
protected static final String[] RENAME_TABLE_TEMPLATE
protected static final String[] REWORD_TEMPLATE
protected static final int[] SQL_VARCHAR_TYPES
protected static final String[] TEMPLATE
protected static final Pattern columnTypePattern
protected BaseDB(com.liferay.portal.kernel.dao.db.DBType dbType, int majorVersion, int minorVersion)
public void addIndexes(Connection connection, List<com.liferay.portal.kernel.dao.db.IndexMetadata> indexMetadatas) throws IOException, SQLException
addIndexes
in interface com.liferay.portal.kernel.dao.db.DB
IOException
SQLException
public void alterColumnName(Connection connection, String tableName, String oldColumnName, String newColumnDefinition) throws Exception
alterColumnName
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public void alterColumnType(Connection connection, String tableName, String columnName, String newColumnType) throws Exception
alterColumnType
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public void alterTableAddColumn(Connection connection, String tableName, String columnName, String columnType) throws Exception
alterTableAddColumn
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public void alterTableDropColumn(Connection connection, String tableName, String columnName) throws Exception
alterTableDropColumn
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public abstract String buildSQL(String template) throws IOException, SQLException
buildSQL
in interface com.liferay.portal.kernel.dao.db.DB
IOException
SQLException
public void copyTableRows(Connection connection, String sourceTableName, String targetTableName, Map<String,String> columnNamesMap, Map<String,String> defaultValuesMap) throws Exception
copyTableRows
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public void copyTableStructure(Connection connection, String tableName, String newTableName) throws Exception
copyTableStructure
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public List<com.liferay.portal.kernel.dao.db.IndexMetadata> dropIndexes(Connection connection, String tableName, String columnName) throws IOException, SQLException
dropIndexes
in interface com.liferay.portal.kernel.dao.db.DB
IOException
SQLException
public com.liferay.portal.kernel.dao.db.DBType getDBType()
getDBType
in interface com.liferay.portal.kernel.dao.db.DB
public String getDefaultValue(String columnDef)
getDefaultValue
in interface com.liferay.portal.kernel.dao.db.DB
public List<com.liferay.portal.kernel.dao.db.Index> getIndexes(Connection connection) throws SQLException
getIndexes
in interface com.liferay.portal.kernel.dao.db.DB
SQLException
public ResultSet getIndexResultSet(Connection connection, String tableName, boolean onlyUnique) throws SQLException
getIndexResultSet
in interface com.liferay.portal.kernel.dao.db.DB
SQLException
public int getMajorVersion()
getMajorVersion
in interface com.liferay.portal.kernel.dao.db.DB
public int getMinorVersion()
getMinorVersion
in interface com.liferay.portal.kernel.dao.db.DB
public String[] getPrimaryKeyColumnNames(Connection connection, String tableName) throws SQLException
getPrimaryKeyColumnNames
in interface com.liferay.portal.kernel.dao.db.DB
SQLException
public Integer getSQLType(String templateType)
getSQLType
in interface com.liferay.portal.kernel.dao.db.DB
public Integer getSQLTypeDecimalDigits(String templateType)
getSQLTypeDecimalDigits
in interface com.liferay.portal.kernel.dao.db.DB
public Integer getSQLTypeSize(String templateType)
getSQLTypeSize
in interface com.liferay.portal.kernel.dao.db.DB
public String getTemplateBlob()
getTemplateBlob
in interface com.liferay.portal.kernel.dao.db.DB
public String getTemplateFalse()
getTemplateFalse
in interface com.liferay.portal.kernel.dao.db.DB
public String getTemplateTrue()
getTemplateTrue
in interface com.liferay.portal.kernel.dao.db.DB
public String getVersionString()
getVersionString
in interface com.liferay.portal.kernel.dao.db.DB
public boolean isSupportsAlterColumnName()
isSupportsAlterColumnName
in interface com.liferay.portal.kernel.dao.db.DB
public boolean isSupportsAlterColumnType()
isSupportsAlterColumnType
in interface com.liferay.portal.kernel.dao.db.DB
public boolean isSupportsDBPartition()
isSupportsDBPartition
in interface com.liferay.portal.kernel.dao.db.DB
public boolean isSupportsInlineDistinct()
isSupportsInlineDistinct
in interface com.liferay.portal.kernel.dao.db.DB
public boolean isSupportsQueryingAfterException()
isSupportsQueryingAfterException
in interface com.liferay.portal.kernel.dao.db.DB
public boolean isSupportsScrollableResults()
isSupportsScrollableResults
in interface com.liferay.portal.kernel.dao.db.DB
public boolean isSupportsStringCaseSensitiveQuery()
isSupportsStringCaseSensitiveQuery
in interface com.liferay.portal.kernel.dao.db.DB
public boolean isSupportsUpdateWithInnerJoin()
isSupportsUpdateWithInnerJoin
in interface com.liferay.portal.kernel.dao.db.DB
public void process(com.liferay.petra.function.UnsafeConsumer<Long,Exception> unsafeConsumer) throws Exception
process
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public void removePrimaryKey(Connection connection, String tableName) throws Exception
removePrimaryKey
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public void renameTables(Connection connection, com.liferay.portal.kernel.util.ObjectValuePair<String,String>... tableNameObjectValuePairs) throws Exception
renameTables
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public void runSQL(Connection connection, String sql) throws IOException, SQLException
runSQL
in interface com.liferay.portal.kernel.dao.db.DB
IOException
SQLException
public void runSQL(Connection connection, String[] sqls) throws IOException, SQLException
runSQL
in interface com.liferay.portal.kernel.dao.db.DB
IOException
SQLException
public void runSQL(String sql) throws IOException, SQLException
runSQL
in interface com.liferay.portal.kernel.dao.db.DB
IOException
SQLException
public void runSQL(String[] sqls) throws IOException, SQLException
runSQL
in interface com.liferay.portal.kernel.dao.db.DB
IOException
SQLException
public void runSQLTemplateString(Connection connection, String template, boolean failOnError) throws IOException, javax.naming.NamingException, SQLException
runSQLTemplateString
in interface com.liferay.portal.kernel.dao.db.DB
IOException
javax.naming.NamingException
SQLException
public void runSQLTemplateString(String template, boolean failOnError) throws IOException, javax.naming.NamingException, SQLException
runSQLTemplateString
in interface com.liferay.portal.kernel.dao.db.DB
IOException
javax.naming.NamingException
SQLException
public void setSupportsStringCaseSensitiveQuery(boolean supportsStringCaseSensitiveQuery)
setSupportsStringCaseSensitiveQuery
in interface com.liferay.portal.kernel.dao.db.DB
public AutoCloseable syncTables(Connection connection, String sourceTableName, String targetTableName, Map<String,String> columnNamesMap, Map<String,String> defaultValuesMap) throws Exception
syncTables
in interface com.liferay.portal.kernel.dao.db.DB
Exception
public void updateIndexes(Connection connection, String tableName, String indexesSQL, boolean dropIndexes) throws Exception
updateIndexes
in interface com.liferay.portal.kernel.dao.db.DB
Exception
protected void addPrimaryKey(Connection connection, String tableName, String[] columnNames) throws IOException, SQLException
IOException
SQLException
protected String[] buildColumnNameTokens(String line)
protected String[] buildColumnTypeTokens(String line)
protected String[] buildTableNameTokens(String line)
protected void createSyncDeleteTrigger(Connection connection, String sourceTableName, String targetTableName, String triggerName, String[] sourcePrimaryKeyColumnNames, String[] targetPrimaryKeyColumnNames) throws Exception
Exception
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
Exception
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
Exception
protected void doRenameTables(Connection connection, com.liferay.portal.kernel.util.ObjectValuePair<String,String>... tableNameObjectValuePairs) throws Exception
Exception
protected Set<String> dropIndexes(Connection connection, String indexesSQL, List<com.liferay.portal.kernel.dao.db.Index> indexes) throws IOException, SQLException
IOException
SQLException
protected void dropTrigger(Connection connection, String tableName, String triggerName) throws Exception
Exception
protected String getCopyTableStructureSQL(String tableName, String newTableName)
protected List<com.liferay.portal.kernel.dao.db.IndexMetadata> getIndexes(Connection connection, String tableName, String columnName, boolean onlyUnique) throws SQLException
SQLException
protected String getRenameTableSQL(String oldTableName, String newTableName)
protected abstract int[] getSQLTypes()
protected Map<String,Integer> getSQLVarcharSizes()
protected abstract String[] getTemplate()
protected boolean isSupportsDDLRollback()
protected boolean isSupportsDuplicatedIndexName()
protected String limitColumnLength(String column, int length)
protected String replaceTemplate(String template)
protected abstract String reword(String data) throws IOException, SQLException
IOException
SQLException