// Build where clause expression.
Expression whereClause = null;
Expression builder = new ExpressionBuilder();
AbstractRecord modifyRow = new DatabaseRecord();
if(queryType == pk) {
Iterator<DatabaseField> it = getReferenceDescriptor().getPrimaryKeyFields().iterator();
while(it.hasNext()) {
DatabaseField pkField = it.next();
DatabaseField sourceField = targetForeignKeyToSourceKeys.get(pkField);
DatabaseField parameterField = sourceField != null ? sourceField : pkField;
Expression expression = builder.getField(pkField).equal(builder.getParameter(parameterField));
whereClause = expression.and(whereClause);
}
modifyRow.add(this.listOrderField, null);
} else {
Iterator<Map.Entry<DatabaseField, DatabaseField>> it = targetForeignKeyToSourceKeys.entrySet().iterator();
while(it.hasNext()) {
Map.Entry<DatabaseField, DatabaseField> entry = it.next();
Expression expression = builder.getField(entry.getKey()).equal(builder.getParameter(entry.getValue()));
whereClause = expression.and(whereClause);
}
Expression listOrderExpression;
if(queryType == bulk) {
listOrderExpression = builder.getField(this.listOrderField).between(builder.getParameter(min), builder.getParameter(max));
modifyRow.add(this.listOrderField, ExpressionMath.add(builder.getField(this.listOrderField), builder.getParameter(shift)));
} else {
listOrderExpression = builder.getField(this.listOrderField).equal(builder.getParameter(min));
modifyRow.add(this.listOrderField, null);
}
whereClause = listOrderExpression.and(whereClause);
}
SQLUpdateStatement statement = new SQLUpdateStatement();