Class DeleteNotExistsExecutor
java.lang.Object
org.alfresco.repo.domain.schema.script.DeleteNotExistsExecutor
- All Implemented Interfaces:
StatementExecutor
- Direct Known Subclasses:
DeleteNotExistsV3Executor,MySQLDeleteNotExistsExecutor
The
--DELETE_NOT_EXISTS primaryTable.columnName,secondaryTable1.columnName1,...,secondaryTableN.columnNameN batch.size.property statement is used to delete all the items that don't have any corresponding key in any of the secondary tables (e.g. secondaryTable1.columnName1,...,secondaryTableN.columnNameN).
The processing of the tables and the actual deletes are done in batches to support a high volume of data. It can be influenced using: system.delete_not_exists.batchsize and/or system.delete_not_exists.delete_batchsize
The statement can be executed in read only mode using: system.delete_not_exists.read_only.
In case of high volume of data we can limit the processing time using: system.delete_not_exists.timeout_seconds.- Author:
- Cristian Turlica
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected Connectionprotected intprotected longprotected Propertiesstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected booleanprotected Date -
Constructor Summary
ConstructorsConstructorDescriptionDeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties globalProperties) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected voidcloseQuietly(ResultSet resultSet) protected voidcloseQuietly(ResultSet[] resultSets) protected voidcloseQuietly(Statement statement) protected voidcloseQuietly(Statement[] statements) protected StringcreatePreparedDeleteStatement(String tableName, String idColumnName, int deleteBatchSize, String whereClause) protected StringcreatePreparedSelectStatement(String tableName, String columnName, String whereClause) protected voiddeleteFromPrimaryTable(PreparedStatement deletePrepStmt, Set<Long> deleteIds, String primaryTableName) voidexecute()protected LonggetColumnValueById(ResultSet resultSet, String columnId) protected Long[]getSecondaryIds(ResultSet[] secondaryResultSets, Pair<String, String>[] tableColumn) protected ResultSet[]getSecondaryResultSets(PreparedStatement[] preparedStatements) protected booleanprotected booleanprotected voidprotected voidprocess(Pair<String, String>[] tableColumn, Long[] tableUpperLimits, String[] optionalWhereClauses, Long skipToId) protected LongprocessPrimaryTableResultSet(PreparedStatement primaryPrepStmt, PreparedStatement[] secondaryPrepStmts, PreparedStatement deletePrepStmt, Set<Long> deleteIds, String primaryTableName, String primaryColumnName, Pair<String, String>[] tableColumn)
-
Field Details
-
PROPERTY_BATCH_SIZE
- See Also:
-
PROPERTY_DELETE_BATCH_SIZE
- See Also:
-
PROPERTY_READ_ONLY
- See Also:
-
PROPERTY_TIMEOUT_SECONDS
- See Also:
-
connection
-
globalProperties
-
readOnly
protected boolean readOnly -
deleteBatchSize
protected int deleteBatchSize -
batchSize
protected int batchSize -
deletedCount
protected long deletedCount -
startTime
-
-
Constructor Details
-
DeleteNotExistsExecutor
public DeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties globalProperties)
-
-
Method Details
-
checkProperties
public void checkProperties() -
execute
- Specified by:
executein interfaceStatementExecutor- Throws:
Exception
-
process
protected void process(Pair<String, String>[] tableColumn, Long[] tableUpperLimits, String[] optionalWhereClauses) throws SQLException- Throws:
SQLException
-
isTimeoutExceeded
protected boolean isTimeoutExceeded() -
processPrimaryTableResultSet
protected Long processPrimaryTableResultSet(PreparedStatement primaryPrepStmt, PreparedStatement[] secondaryPrepStmts, PreparedStatement deletePrepStmt, Set<Long> deleteIds, String primaryTableName, String primaryColumnName, Pair<String, String>[] tableColumn) throws SQLException- Throws:
SQLException
-
deleteFromPrimaryTable
protected void deleteFromPrimaryTable(PreparedStatement deletePrepStmt, Set<Long> deleteIds, String primaryTableName) throws SQLException - Throws:
SQLException
-
isLess
-
createPreparedSelectStatement
-
createPreparedDeleteStatement
-
getColumnValueById
- Throws:
SQLException
-
getSecondaryResultSets
protected ResultSet[] getSecondaryResultSets(PreparedStatement[] preparedStatements) throws SQLException - Throws:
SQLException
-
getSecondaryIds
protected Long[] getSecondaryIds(ResultSet[] secondaryResultSets, Pair<String, String>[] tableColumn) throws SQLException- Throws:
SQLException
-
closeQuietly
-
closeQuietly
-
closeQuietly
-
closeQuietly
-
process
protected void process(Pair<String, String>[] tableColumn, Long[] tableUpperLimits, String[] optionalWhereClauses, Long skipToId) throws SQLException- Throws:
SQLException
-