{"record":{"id":"f2a3b84682c3cb09","repo":"jeecgboot/JeecgBoot","slug":"error-f2a3b8","errorCode":null,"errorMessage":"未找到对应实体","messagePattern":"未找到对应实体","errorType":"exception","errorClass":"JeecgBootException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai","lineNumber":59,"sourceCode":"\t    ${entityName?uncap_first}.set${hasChildrenField?cap_first}(I${entityName}Service.NOCHILD);\n\t\tif(oConvertUtils.isEmpty(${entityName?uncap_first}.get${pidFieldName?cap_first}())){\n\t\t\t${entityName?uncap_first}.set${pidFieldName?cap_first}(I${entityName}Service.ROOT_PID_VALUE);\n\t\t}else{\n\t\t\t//如果当前节点父ID不为空 则设置父节点的hasChildren 为1\n\t\t\t${entityName} parent = baseMapper.selectById(${entityName?uncap_first}.get${pidFieldName?cap_first}());\n\t\t\tif(parent!=null && !\"1\".equals(parent.get${hasChildrenField?cap_first}())){\n\t\t\t\tparent.set${hasChildrenField?cap_first}(\"1\");\n\t\t\t\tbaseMapper.updateById(parent);\n\t\t\t}\n\t\t}\n\t\tbaseMapper.insert(${entityName?uncap_first});\n\t}\n\t\n\t@Override\n\tpublic void update${entityName}(${entityName} ${entityName?uncap_first}) {\n\t\t${entityName} entity = this.getById(${entityName?uncap_first}.getId());\n\t\tif(entity==null) {\n\t\t\tthrow new JeecgBootException(\"未找到对应实体\");\n\t\t}\n\t\tString old_pid = entity.get${pidFieldName?cap_first}();\n\t\tString new_pid = ${entityName?uncap_first}.get${pidFieldName?cap_first}();\n\t\tif(!old_pid.equals(new_pid)) {\n\t\t\tupdateOldParentNode(old_pid);\n\t\t\tif(oConvertUtils.isEmpty(new_pid)){\n\t\t\t\t${entityName?uncap_first}.set${pidFieldName?cap_first}(I${entityName}Service.ROOT_PID_VALUE);\n\t\t\t}\n\t\t\tif(!I${entityName}Service.ROOT_PID_VALUE.equals(${entityName?uncap_first}.get${pidFieldName?cap_first}())) {\n\t\t\t\tbaseMapper.updateTreeNodeStatus(${entityName?uncap_first}.get${pidFieldName?cap_first}(), I${entityName}Service.HASCHILD);\n\t\t\t}\n\t\t}\n\t\tbaseMapper.updateById(${entityName?uncap_first});\n\t}\n\t\n\t@Override\n\t@Transactional(rollbackFor = Exception.class)\n\tpublic void delete${entityName}(String id) throws JeecgBootException {","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/service/impl/${entityName}ServiceImpl.javai#L41-L77","documentation":"Thrown as JeecgBootException from the generated service's update method when the entity to update cannot be found by its ID. This error originates from a FreeMarker code-generation template (${entityName}ServiceImpl.javai) used by jeecg-boot's online code generator to produce tree-structured CRUD services. At runtime, the generated code calls getById() and throws if the result is null, preventing a blind update of a non-existent record.","triggerScenarios":"A PUT/POST update request to the generated tree CRUD controller where the entity ID in the request body does not match any existing database row — e.g., the record was deleted by another user, the ID was fabricated/tampered, or a stale frontend form submitted an old ID.","commonSituations":"Concurrent deletion: user A deletes the record while user B has the edit form open and submits; frontend caches stale IDs; UUID/primary key mismatch between frontend and database; soft-delete filter excludes the record; wrong data source routing in a multi-tenant setup.","solutions":["Verify the entity ID exists before submitting the update — refresh the list or detail page.","Handle concurrent edits: on catch, inform the user the record was modified or deleted by another user.","Check for soft-delete logic that might filter out the record despite it existing in the table.","Ensure the correct data source / tenant context is active for multi-tenant deployments."],"exampleFix":"// before — no existence check in caller\nservice.updateEntity(dto);  // throws if not found\n// after — check first\nif (service.getById(dto.getId()) == null) {\n    return Result.error(\"Record not found or was deleted\");\n}\nservice.updateEntity(dto);","handlingStrategy":"validation","validationCode":"// Check existence before update\nEntity existing = service.getById(dto.getId());\nif (existing == null) {\n    return Result.error(\"Record not found, it may have been deleted.\");\n}\nservice.updateEntity(dto);","typeGuard":"boolean entityExists(IService<Entity> service, String id) {\n    return id != null && service.getById(id) != null;\n}","tryCatchPattern":"try {\n    service.updateEntity(dto);\n} catch (JeecgBootException e) {\n    if (\"未找到对应实体\".equals(e.getMessage())) {\n        return Result.error(\"Record not found or was deleted by another user.\");\n    }\n    throw e;\n}","preventionTips":["Refresh the detail/form data before submitting an update.","Implement optimistic locking or version checks for concurrent edits.","Handle the not-found case gracefully in the controller layer.","Check for soft-delete filters that may hide the record."],"tags":["jeecg-boot","crud","template","tree","runtime","generated-code"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}