Step 3: After the record has been modified, when ready to update the record, do a select query first to read the time stamp or version number for the same record to ensure that it has not been modified. if the "timestamp" or the "version number" has changed, you need to throw the above exception and abort modifying the record as it had been modified by another user.

@Override
public AdjustmentDetail modifyAdjustment(AdjustmentDetail adjDetail)
{
if (adjDetail == null)
{
throw new RuntimeException("adjDetail is null");
}
int noOfRecords = 0;
String inactiveFlag;
try
{
//check if the record has been modified.
Integer adjustmentModifiedTimestamp = getAdjustmentModifiedTimestamp(adjDetail.getDetailId());
//logic to modify adjustments go here
//every time the record is modified, the timestamp or version number is incremented.
}
catch (Exception e)
{
logger.error("Error updating adjustment detail: ", e);
}
if (noOfRecords == 0) throw new ValidationException("The adjustment was not updated. It may be the record you are trying to update has been updated by another user. Try refreshing your data and update again.");
logger.info("No of adjustment details updated = " + noOfRecords);
return adjDetail;
}