If find() method is implemented correctly, it has a boolean parameter saying whether the record should be selected for update. You just need to set it to true. Throw away the call of selectForUpdate(), because it does nothing. Here is the new code:
ttsBegin;
XxxxxxTable xxxxxTable = XxxxxxTable::find(xxxxx.StoresReqId, true);
if (xxxxxTable)
{
xxxxxTable.xxxxxDepartment = _attributeValue.getName();
xxxxxTable.doUpdate();
}
ttsCommit;
Unlike GirishS's code, this would work even with pessimistic locking.
An alternative solution would be using update_recordset. Then you wouldn't even have to load the record from database.
By the way, thing carefully whether you should use doUpdate() instead of update(). There may be important logic in update() that you'd skip. And if no such logic is there today, someone may add it tomorrow.
Also, a good idea would be removing the extra line indentation before pasting code. Compare my code with code snippets above