}
// modify query for locking only if locking has not been configured
if (isDefaultLock()) {
setWasDefaultLockMode(true);
ForUpdateOfClause lockingClause = null;
if (hasJoining()) {
lockingClause = getJoinedAttributeManager().setupLockingClauseForJoinedExpressions(lockingClause, getSession());
}
if (this.descriptor.hasPessimisticLockingPolicy()) {
lockingClause = new ForUpdateOfClause();
lockingClause.setLockMode(this.descriptor.getCMPPolicy().getPessimisticLockingPolicy().getLockingMode());
lockingClause.addLockedExpression(getExpressionBuilder());
}
if (lockingClause != null) {
this.lockingClause = lockingClause;
// SPECJ: Locking not compatible with distinct for batch reading.
dontUseDistinct();