}
public void updateObjectWithWriteValue(ObjectLevelModifyQuery query, Object lockValue){
AbstractSession session = query.getSession();
Object object = query.getObject();
ObjectChangeSet objectChangeSet = query.getObjectChangeSet();
if (objectChangeSet == null) {
if (session.isUnitOfWork() && (((UnitOfWorkImpl)session).getUnitOfWorkChangeSet() != null)) {
// For aggregate collections the change set may be null, as they use the old commit still.
objectChangeSet = (ObjectChangeSet)((UnitOfWorkImpl)session).getUnitOfWorkChangeSet().getObjectChangeSetForClone(object);
}
}
// PERF: handle normal case faster.
if (this.lockMapping != null) {
this.lockMapping.setAttributeValueInObject(object, this.lockMapping.getAttributeValue(lockValue, session));
if (objectChangeSet != null) {
objectChangeSet.setWriteLockValue(lockValue);
objectChangeSet.updateChangeRecordForAttribute(this.lockMapping, lockValue, session);
}
} else {
// CR#3173211
// If the value is stored in the cache or object, there still may
// be read-only mappings for it, so the object must always be updated for
// any writable or read-only mappings for the version value.
// Reuse the method used for returning as has the same requirements.
ObjectBuilder objectBuilder = this.descriptor.getObjectBuilder();
AbstractRecord record = objectBuilder.createRecord(1, session);
record.put(this.writeLockField, lockValue);
objectBuilder.assignReturnRow(object, session, record);
if (objectChangeSet != null) {
objectChangeSet.setWriteLockValue(lockValue);
query.getQueryMechanism().updateChangeSet(this.descriptor, objectChangeSet, record, object);
}
}
}