Package com.liferay.portal.dao.db
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
- Author:
- Alexander Chow, Ganesh Ram, Brian Wing Shun Chan, Daniel Kocsis
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
protected static final String
protected static final String
protected static final Pattern
protected static final String
protected static final String
protected static final String
protected static final String[]
protected static final String[]
protected static final int[]
protected static final String[]
Fields inherited from interface com.liferay.portal.kernel.dao.db.DB
SQL_SIZE_NONE, SQL_VARCHAR_MAX_SIZE, SQL_VARCHAR_MAX_SIZE_THRESHOLD
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseDB
(com.liferay.portal.kernel.dao.db.DBType dbType, int majorVersion, int minorVersion) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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) List<com.liferay.portal.kernel.dao.db.IndexMetadata>
dropIndexes
(Connection connection, String tableName, String columnName) dropIndexes
(Connection connection, String indexesSQL, List<com.liferay.portal.kernel.dao.db.Index> indexes) protected void
dropTrigger
(Connection connection, String tableName, String triggerName) protected String
getCopyTableStructureSQL
(String tableName, String newTableName) com.liferay.portal.kernel.dao.db.DBType
getDefaultValue
(String columnDef) protected String
getIndexColumnName
(String indexColumnName) List<com.liferay.portal.kernel.dao.db.Index>
getIndexes
(Connection connection) List<com.liferay.portal.kernel.dao.db.IndexMetadata>
getIndexMetadatas
(Connection connection, String tableName, String columnName, boolean onlyUnique) getIndexResultSet
(Connection connection, String tableName, boolean onlyUnique) int
int
String[]
getPrimaryKeyColumnNames
(Connection connection, String tableName) protected String
getRenameTableSQL
(String oldTableName, String newTableName) getSQLType
(String templateType) getSQLTypeDecimalDigits
(String templateType) protected abstract int[]
getSQLTypeSize
(String templateType) protected abstract String[]
boolean
boolean
boolean
protected boolean
protected boolean
boolean
boolean
boolean
boolean
boolean
protected String
limitColumnLength
(String column, int length) void
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
void
void
void
runSQL
(Connection connection, String sql) void
runSQL
(Connection connection, String[] sqls) void
runSQLTemplate
(String template, boolean failOnError) void
runSQLTemplate
(Connection connection, String template, boolean failOnError) void
setSupportsStringCaseSensitiveQuery
(boolean supportsStringCaseSensitiveQuery) 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) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.liferay.portal.kernel.dao.db.DB
getNewUuidFunctionName, getPopulateSQL, getRecreateSQL, isSupportsNewUuidFunction, runSQL, runSQL, runSQLTemplateString, runSQLTemplateString
-
Field Details
-
ALTER_COLUMN_NAME
- See Also:
-
ALTER_COLUMN_TYPE
- See Also:
-
ALTER_TABLE_NAME
- See Also:
-
CREATE_TABLE
- See Also:
-
DROP_INDEX
- See Also:
-
DROP_PRIMARY_KEY
- See Also:
-
RENAME_TABLE_TEMPLATE
-
REWORD_TEMPLATE
-
SQL_VARCHAR_TYPES
protected static final int[] SQL_VARCHAR_TYPES -
TEMPLATE
-
columnTypePattern
-
-
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 interfacecom.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 interfacecom.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 interfacecom.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 interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
Exception
-
alterTableDropColumn
public void alterTableDropColumn(Connection connection, String tableName, String columnName) throws Exception - Specified by:
alterTableDropColumn
in interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
Exception
-
buildSQL
- Specified by:
buildSQL
in interfacecom.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, throws ExceptionString> defaultValuesMap) - Specified by:
copyTableRows
in interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
Exception
-
copyTableStructure
public void copyTableStructure(Connection connection, String tableName, String newTableName) throws Exception - Specified by:
copyTableStructure
in interfacecom.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 interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
IOException
SQLException
-
getDBType
public com.liferay.portal.kernel.dao.db.DBType getDBType()- Specified by:
getDBType
in interfacecom.liferay.portal.kernel.dao.db.DB
-
getDefaultValue
- Specified by:
getDefaultValue
in interfacecom.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 interfacecom.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 interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
SQLException
-
getIndexResultSet
public ResultSet getIndexResultSet(Connection connection, String tableName, boolean onlyUnique) throws SQLException - Specified by:
getIndexResultSet
in interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
SQLException
-
getMajorVersion
public int getMajorVersion()- Specified by:
getMajorVersion
in interfacecom.liferay.portal.kernel.dao.db.DB
-
getMinorVersion
public int getMinorVersion()- Specified by:
getMinorVersion
in interfacecom.liferay.portal.kernel.dao.db.DB
-
getPrimaryKeyColumnNames
public String[] getPrimaryKeyColumnNames(Connection connection, String tableName) throws SQLException - Specified by:
getPrimaryKeyColumnNames
in interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
SQLException
-
getSQLType
- Specified by:
getSQLType
in interfacecom.liferay.portal.kernel.dao.db.DB
-
getSQLTypeDecimalDigits
- Specified by:
getSQLTypeDecimalDigits
in interfacecom.liferay.portal.kernel.dao.db.DB
-
getSQLTypeSize
- Specified by:
getSQLTypeSize
in interfacecom.liferay.portal.kernel.dao.db.DB
-
getTemplateBlob
- Specified by:
getTemplateBlob
in interfacecom.liferay.portal.kernel.dao.db.DB
-
getTemplateFalse
- Specified by:
getTemplateFalse
in interfacecom.liferay.portal.kernel.dao.db.DB
-
getTemplateTrue
- Specified by:
getTemplateTrue
in interfacecom.liferay.portal.kernel.dao.db.DB
-
getVersionString
- Specified by:
getVersionString
in interfacecom.liferay.portal.kernel.dao.db.DB
-
isSupportsAlterColumnName
public boolean isSupportsAlterColumnName()- Specified by:
isSupportsAlterColumnName
in interfacecom.liferay.portal.kernel.dao.db.DB
-
isSupportsAlterColumnType
public boolean isSupportsAlterColumnType()- Specified by:
isSupportsAlterColumnType
in interfacecom.liferay.portal.kernel.dao.db.DB
-
isSupportsDBPartition
public boolean isSupportsDBPartition()- Specified by:
isSupportsDBPartition
in interfacecom.liferay.portal.kernel.dao.db.DB
-
isSupportsInlineDistinct
public boolean isSupportsInlineDistinct()- Specified by:
isSupportsInlineDistinct
in interfacecom.liferay.portal.kernel.dao.db.DB
-
isSupportsQueryingAfterException
public boolean isSupportsQueryingAfterException()- Specified by:
isSupportsQueryingAfterException
in interfacecom.liferay.portal.kernel.dao.db.DB
-
isSupportsScrollableResults
public boolean isSupportsScrollableResults()- Specified by:
isSupportsScrollableResults
in interfacecom.liferay.portal.kernel.dao.db.DB
-
isSupportsStringCaseSensitiveQuery
public boolean isSupportsStringCaseSensitiveQuery()- Specified by:
isSupportsStringCaseSensitiveQuery
in interfacecom.liferay.portal.kernel.dao.db.DB
-
isSupportsUpdateWithInnerJoin
public boolean isSupportsUpdateWithInnerJoin()- Specified by:
isSupportsUpdateWithInnerJoin
in interfacecom.liferay.portal.kernel.dao.db.DB
-
process
public void process(com.liferay.petra.function.UnsafeConsumer<Long, Exception> unsafeConsumer) throws Exception- Specified by:
process
in interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
Exception
-
removePrimaryKey
- Specified by:
removePrimaryKey
in interfacecom.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 interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
Exception
-
runSQL
- Specified by:
runSQL
in interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
IOException
SQLException
-
runSQL
- Specified by:
runSQL
in interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
IOException
SQLException
-
runSQL
- Specified by:
runSQL
in interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
IOException
SQLException
-
runSQL
- Specified by:
runSQL
in interfacecom.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 interfacecom.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 interfacecom.liferay.portal.kernel.dao.db.DB
- Throws:
IOException
NamingException
SQLException
-
setSupportsStringCaseSensitiveQuery
public void setSupportsStringCaseSensitiveQuery(boolean supportsStringCaseSensitiveQuery) - Specified by:
setSupportsStringCaseSensitiveQuery
in interfacecom.liferay.portal.kernel.dao.db.DB
-
syncTables
public AutoCloseable syncTables(Connection connection, String sourceTableName, String targetTableName, Map<String, String> columnNamesMap, Map<String, throws ExceptionString> defaultValuesMap) - Specified by:
syncTables
in interfacecom.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 interfacecom.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
-
buildColumnTypeTokens
-
buildTableNameTokens
-
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
-
getIndexColumnName
-
getRenameTableSQL
-
getSQLTypes
protected abstract int[] getSQLTypes() -
getSQLVarcharSizes
-
getTemplate
-
isSupportsDDLRollback
protected boolean isSupportsDDLRollback() -
isSupportsDuplicatedIndexName
protected boolean isSupportsDuplicatedIndexName() -
limitColumnLength
-
replaceTemplate
-
reword
- Throws:
IOException
SQLException
-