{"record":{"id":"2c57b73f9ca67992","repo":"paascloud/paascloud-master","slug":"uac10011026","errorCode":"UAC10011026","errorMessage":"ErrorCodeEnum.UAC10011026","messagePattern":"ErrorCodeEnum\\.UAC10011026","errorType":"error_code","errorClass":"UacBizException","httpStatus":null,"severity":"error","filePath":"paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacUserServiceImpl.java","lineNumber":229,"sourceCode":"\t\t\tuser.setId(userId);\n\t\t\tuser.setLoginName(loginName);\n\t\t\tuser.setType(UacUserTypeEnum.OPERATE.getKey());\n\t\t\tuser.setUserSource(UacUserSourceEnum.INSERT.getKey());\n\t\t\t// TODO 校验状态是否合法\n\t\t\tuacUserMapper.insertSelective(user);\n\n\t\t\t// 2.添加组织关联\n\t\t\tUacGroupUser groupUser = new UacGroupUser();\n\t\t\tgroupUser.setGroupId(user.getGroupId());\n\t\t\tgroupUser.setUserId(userId);\n\t\t\tuacGroupUserService.save(groupUser);\n\t\t} else {\n\t\t\tUacUser uacUser = uacUserMapper.selectByPrimaryKey(user.getId());\n\t\t\tPreconditions.checkArgument(uacUser != null, \"用户不存在\");\n\t\t\t// 1.更新用户信息\n\t\t\tint updateInt = uacUserMapper.updateUacUser(user);\n\t\t\tif (updateInt < 1) {\n\t\t\t\tthrow new UacBizException(ErrorCodeEnum.UAC10011026, user.getId());\n\t\t\t}\n\t\t\t// 2.绑定组织信息\n\t\t\tUacGroupUser uacGroupUser = uacGroupUserService.queryByUserId(user.getId());\n\t\t\tif (uacGroupUser == null) {\n\t\t\t\t// 添加组织关联\n\t\t\t\tUacGroupUser groupUser = new UacGroupUser();\n\t\t\t\tgroupUser.setGroupId(user.getGroupId());\n\t\t\t\tgroupUser.setUserId(user.getId());\n\t\t\t\tuacGroupUserService.save(groupUser);\n\t\t\t} else {\n\t\t\t\t//修改组织\n\t\t\t\tUacGroupUser groupUser = new UacGroupUser();\n\t\t\t\tgroupUser.setUserId(user.getId());\n\t\t\t\tgroupUser.setGroupId(user.getGroupId());\n\t\t\t\tuacGroupUserService.updateByUserId(groupUser);\n\t\t\t}\n\t\t}\n","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-provider/paascloud-provider-uac/src/main/java/com/paascloud/provider/service/impl/UacUserServiceImpl.java#L211-L247","documentation":"UacBizException with ErrorCodeEnum.UAC10011026 (\"更新用户失败, userId=%\") is thrown by UacUserServiceImpl.saveUacUser on the update branch when uacUserMapper.updateUacUser(user) affects fewer than 1 row. Although the user record was found by primary key, the UPDATE matched no rows.","triggerScenarios":"Calling saveUacUser with a non-null user.getId() where the UPDATE statement updates 0 rows — typically a concurrent delete between the selectByPrimaryKey check and the update, or updateUacUser's WHERE conditions (e.g. version/optimistic-lock column) not matching.","commonSituations":"Optimistic-locking version conflicts when two admins edit the same user; user deleted in another session; mapping SQL for updateUacUser filtering on a column that is null in the passed entity.","solutions":["Re-fetch the user, merge changes onto the fresh entity, and retry the update once","Check for concurrent modification: compare version numbers and surface a 'record changed by someone else' error to the client","Verify the updateUacUser mapper XML WHERE clause actually matches the row for the given entity state","Confirm the user still exists before update and return UAC10011011 instead if it was deleted"],"exampleFix":"// before\nint updateInt = uacUserMapper.updateUacUser(user);\nif (updateInt < 1) {\n    throw new UacBizException(ErrorCodeEnum.UAC10011026, user.getId());\n}\n// after\nint updateInt = uacUserMapper.updateUacUser(user);\nif (updateInt < 1) {\n    if (uacUserMapper.selectByPrimaryKey(user.getId()) == null) {\n        throw new UacBizException(ErrorCodeEnum.UAC10011011, user.getId());\n    }\n    throw new UacBizException(ErrorCodeEnum.UAC10011026, user.getId());\n}","handlingStrategy":"try-catch","validationCode":"if (user.getId() != null && uacUserMapper.selectByPrimaryKey(user.getId()) == null) {\n    throw new BusinessException(\"user no longer exists\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    uacUserService.saveUacUser(user, initPwd, authResDto);\n} catch (UacBizException e) {\n    if (e.getCode() == 10011026) { /* reload entity, merge, retry once */ }\n    else throw e;\n}","preventionTips":["Reload the entity before update to avoid stale versions","Use optimistic locking consistently and handle version conflicts","Keep updateUacUser mapper WHERE clause simple (primary key based)"],"tags":["database-update","optimistic-locking","user-management"],"backgroundTag":"database-write-failed","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}