Class DeleteNotExistsExecutor
- java.lang.Object
-
- org.alfresco.repo.domain.schema.script.DeleteNotExistsExecutor
-
- All Implemented Interfaces:
StatementExecutor
- Direct Known Subclasses:
MySQLDeleteNotExistsExecutor
public class DeleteNotExistsExecutor extends Object implements StatementExecutor
The--DELETE_NOT_EXISTS primaryTable.columnName,secondaryTable1.columnName1,...,secondaryTableN.columnNameN batch.size.propertystatement 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.batchsizeand/orsystem.delete_not_exists.delete_batchsizeThe 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
Fields Modifier and Type Field Description protected intbatchSizeprotected Connectionconnectionprotected intdeleteBatchSizeprotected longdeletedCountstatic StringPROPERTY_BATCH_SIZEstatic StringPROPERTY_DELETE_BATCH_SIZEstatic StringPROPERTY_READ_ONLYstatic StringPROPERTY_TIMEOUT_SECONDSprotected booleanreadOnlyprotected DatestartTime
-
Constructor Summary
Constructors Constructor Description DeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties globalProperties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckProperties()protected 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 booleanisLess(Long primaryId, Long[] secondaryIds)protected booleanisTimeoutExceeded()protected voidprocess(Pair<String,String>[] tableColumn, Long[] tableUpperLimits, String[] optionalWhereClauses)protected LongprocessPrimaryTableResultSet(PreparedStatement primaryPrepStmt, PreparedStatement[] secondaryPrepStmts, PreparedStatement deletePrepStmt, Set<Long> deleteIds, String primaryTableName, String primaryColumnName, Pair<String,String>[] tableColumn)
-
-
-
Field Detail
-
PROPERTY_BATCH_SIZE
public static final String PROPERTY_BATCH_SIZE
- See Also:
- Constant Field Values
-
PROPERTY_DELETE_BATCH_SIZE
public static final String PROPERTY_DELETE_BATCH_SIZE
- See Also:
- Constant Field Values
-
PROPERTY_READ_ONLY
public static final String PROPERTY_READ_ONLY
- See Also:
- Constant Field Values
-
PROPERTY_TIMEOUT_SECONDS
public static final String PROPERTY_TIMEOUT_SECONDS
- See Also:
- Constant Field Values
-
connection
protected Connection connection
-
readOnly
protected boolean readOnly
-
deleteBatchSize
protected int deleteBatchSize
-
batchSize
protected int batchSize
-
deletedCount
protected long deletedCount
-
startTime
protected Date startTime
-
-
Constructor Detail
-
DeleteNotExistsExecutor
public DeleteNotExistsExecutor(Connection connection, String sql, int line, File scriptFile, Properties globalProperties)
-
-
Method Detail
-
checkProperties
public void checkProperties()
-
execute
public void execute() throws Exception- 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
-
createPreparedSelectStatement
protected String createPreparedSelectStatement(String tableName, String columnName, String whereClause)
-
createPreparedDeleteStatement
protected String createPreparedDeleteStatement(String tableName, String idColumnName, int deleteBatchSize, String whereClause)
-
getColumnValueById
protected Long getColumnValueById(ResultSet resultSet, String columnId) throws SQLException
- 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
protected void closeQuietly(Statement statement)
-
closeQuietly
protected void closeQuietly(Statement[] statements)
-
closeQuietly
protected void closeQuietly(ResultSet resultSet)
-
closeQuietly
protected void closeQuietly(ResultSet[] resultSets)
-
-