jeecgboot/JeecgBoot · error · JeecgBootException
未找到对应实体
Error message
未找到对应实体
What it means
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.
Source
Thrown at 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:59
${entityName?uncap_first}.set${hasChildrenField?cap_first}(I${entityName}Service.NOCHILD);
if(oConvertUtils.isEmpty(${entityName?uncap_first}.get${pidFieldName?cap_first}())){
${entityName?uncap_first}.set${pidFieldName?cap_first}(I${entityName}Service.ROOT_PID_VALUE);
}else{
//如果当前节点父ID不为空 则设置父节点的hasChildren 为1
${entityName} parent = baseMapper.selectById(${entityName?uncap_first}.get${pidFieldName?cap_first}());
if(parent!=null && !"1".equals(parent.get${hasChildrenField?cap_first}())){
parent.set${hasChildrenField?cap_first}("1");
baseMapper.updateById(parent);
}
}
baseMapper.insert(${entityName?uncap_first});
}
@Override
public void update${entityName}(${entityName} ${entityName?uncap_first}) {
${entityName} entity = this.getById(${entityName?uncap_first}.getId());
if(entity==null) {
throw new JeecgBootException("未找到对应实体");
}
String old_pid = entity.get${pidFieldName?cap_first}();
String new_pid = ${entityName?uncap_first}.get${pidFieldName?cap_first}();
if(!old_pid.equals(new_pid)) {
updateOldParentNode(old_pid);
if(oConvertUtils.isEmpty(new_pid)){
${entityName?uncap_first}.set${pidFieldName?cap_first}(I${entityName}Service.ROOT_PID_VALUE);
}
if(!I${entityName}Service.ROOT_PID_VALUE.equals(${entityName?uncap_first}.get${pidFieldName?cap_first}())) {
baseMapper.updateTreeNodeStatus(${entityName?uncap_first}.get${pidFieldName?cap_first}(), I${entityName}Service.HASCHILD);
}
}
baseMapper.updateById(${entityName?uncap_first});
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete${entityName}(String id) throws JeecgBootException {View on GitHub (pinned to 96fb33f5ec)
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.
Example fix
// before — no existence check in caller
service.updateEntity(dto); // throws if not found
// after — check first
if (service.getById(dto.getId()) == null) {
return Result.error("Record not found or was deleted");
}
service.updateEntity(dto); Defensive patterns
Strategy: validation
Validate before calling
// Check existence before update
Entity existing = service.getById(dto.getId());
if (existing == null) {
return Result.error("Record not found, it may have been deleted.");
}
service.updateEntity(dto); Type guard
boolean entityExists(IService<Entity> service, String id) {
return id != null && service.getById(id) != null;
} Try / catch
try {
service.updateEntity(dto);
} catch (JeecgBootException e) {
if ("未找到对应实体".equals(e.getMessage())) {
return Result.error("Record not found or was deleted by another user.");
}
throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- 该编码【${parentCode}】不存在,请核实!
- 解析SQL模板异常
- DaoFormat 是 minidao 保留关键字,不允许使用 ,请更改参数定义!
- 表名不合法,存在SQL注入风险!--->{table}
- 字段不合法,存在SQL注入风险!--->{field}
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/f2a3b84682c3cb09.
Report an issue: GitHub.