public void prepareUpdateAll() {
ExpressionBuilder builder = ((UpdateAllQuery)getQuery()).getExpressionBuilder();
HashMap updateClauses = ((UpdateAllQuery)getQuery()).getUpdateClauses();
// Add a statement to update the optimistic locking field if their is one.
OptimisticLockingPolicy policy = getDescriptor().getOptimisticLockingPolicy();
if (policy != null) {
if(policy.getWriteLockField() != null) {
Expression writeLock = builder.getField(policy.getWriteLockField());
Expression writeLockUpdateExpression = policy.getWriteLockUpdateExpression(builder);
if (writeLockUpdateExpression != null) {
// clone it to keep user's original data intact
updateClauses = (HashMap)updateClauses.clone();
updateClauses.put(writeLock, writeLockUpdateExpression);
}