if (hasCustomRemoveTargetQuery) {
return;
}
// Build where clause expression.
Expression whereClause = null;
Expression builder = new ExpressionBuilder();
List<DatabaseField> targetPrimaryKeyFields = getReferenceDescriptor().getPrimaryKeyFields();
int size = targetPrimaryKeyFields.size();
for (int index = 0; index < size; index++) {
DatabaseField targetPrimaryKey = targetPrimaryKeyFields.get(index);
Expression expression = builder.getField(targetPrimaryKey).equal(builder.getParameter(targetPrimaryKey));
whereClause = expression.and(whereClause);
}
AbstractRecord modifyRow = new DatabaseRecord();
size = targetForeignKeyFields.size();
for (int index = 0; index < size; index++) {
DatabaseField targetForeignKey = targetForeignKeyFields.get(index);
modifyRow.put(targetForeignKey, null);
Expression expression = builder.getField(targetForeignKey).equal(builder.getParameter(targetForeignKey));
whereClause = expression.and(whereClause);
}
SQLUpdateStatement statement = new SQLUpdateStatement();
statement.setTable(getReferenceDescriptor().getDefaultTable());
statement.setWhereClause(whereClause);