jeecgboot/JeecgBoot · error · JeecgBootException
查询异常,请检查唯一校验的配置!
Error message
查询异常,请检查唯一校验的配置!
What it means
Thrown by SysDictServiceImpl.duplicateCheckCountSql / duplicateCheckCountSqlNoDataId when a MyBatisSystemException is caught during the SQL duplicate-check query. This JeecgBootException wraps the real cause with a generic message, swallowing the original exception details. The underlying MyBatis error typically stems from a misconfigured duplicate-check definition (wrong field name, wrong table, bad SQL syntax in the dictionary duplicate-check configuration).
Source
Thrown at jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysDictServiceImpl.java:112
dictQueryBlackListHandler.isPass(checkSql);
// 4.执行SQL 查询是否存在值
try{
// 代码逻辑说明: [TV360X-49]postgres日期、年月日时分秒唯一校验报错------------
if(DbTypeUtils.dbTypeIsPostgre(CommonUtils.getDatabaseTypeEnum())){
duplicateCheckVo.setFieldName("CAST("+duplicateCheckVo.getFieldName()+" as text)");
}
if (StringUtils.isNotBlank(duplicateCheckVo.getDataId())) {
// [1].编辑页面校验
count = sysDictMapper.duplicateCheckCountSql(duplicateCheckVo);
} else {
// [2].添加页面校验
count = sysDictMapper.duplicateCheckCountSqlNoDataId(duplicateCheckVo);
}
}catch(MyBatisSystemException e){
log.error(e.getMessage(), e);
String errorCause = "查询异常,请检查唯一校验的配置!";
throw new JeecgBootException(errorCause);
}
// 4.返回结果
if (count == null || count == 0) {
// 该值可用
return true;
} else {
// 该值不可用
log.info("该值不可用,系统中已存在!");
return false;
}
}
/**
* 通过查询指定code 获取字典
* @param code
* @returnView on GitHub (pinned to 96fb33f5ec)
Solutions
- Check the server logs for the original MyBatisSystemException message and root cause — it will show the exact SQL error.
- Verify the table name and field name in the duplicate-check configuration match the actual database schema.
- If using PostgreSQL or another database, confirm the CAST(... as text) syntax is valid for your database dialect.
- Review the duplicateCheckVo data being sent from the frontend to ensure fieldName is a valid column name.
Example fix
// before
} catch (MyBatisSystemException e) {
log.error(e.getMessage(), e);
String errorCause = "查询异常,请检查唯一校验的配置!";
throw new JeecgBootException(errorCause);
}
// after — include root cause in the message for diagnostics
} catch (MyBatisSystemException e) {
log.error(e.getMessage(), e);
String detail = e.getMostSpecificCause().getMessage();
throw new JeecgBootException("查询异常,请检查唯一校验的配置!原因: " + detail);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Validate duplicateCheckVo fields before calling duplicate check
if (duplicateCheckVo == null
|| oConvertUtils.isEmpty(duplicateCheckVo.getFieldName())
|| oConvertUtils.isEmpty(duplicateCheckVo.getTableName())) {
return Result.error("唯一校验参数不完整");
}
// Verify the configured table and field exist in the database schema
// before invoking duplicateCheckCountSql. Type guard
public boolean isDuplicateCheckConfigValid(DuplicateCheckVo vo) {
return vo != null
&& oConvertUtils.isNotEmpty(vo.getFieldName())
&& oConvertUtils.isNotEmpty(vo.getTableName())
&& isValidColumnName(vo.getFieldName());
} Try / catch
try {
boolean isDuplicate = sysDictService.duplicateCheck(dict);
} catch (JeecgBootException e) {
if (e.getMessage().contains("唯一校验的配置")) {
log.error("Duplicate check config error, check field/table mapping", e);
return Result.error("校验配置异常,请联系管理员检查字典唯一校验设置");
}
throw e;
} Prevention
- Always check server logs for the original MyBatisSystemException cause.
- Keep duplicate-check field/table configurations in sync with database schema changes.
- Test duplicate-check SQL against the target database dialect after schema migrations.
When it happens
Trigger: The duplicate-check SQL configured for a dictionary field references a non-existent column or table, has a syntax error, or the duplicateCheckVo.fieldName contains a value that breaks the dynamically constructed SQL. The CAST(... as text) transformation (visible above the try block) may also contribute on certain databases.
Common situations: A developer added a new dictionary item with a duplicate-check rule pointing to a column that was renamed or doesn't exist; database migration changed table/column names without updating the duplicate-check configuration; the duplicateCheckVo.fieldName is user-controlled and injected in a way that breaks SQL.
Related errors
AI-assisted analysis of jeecgboot/JeecgBoot@96fb33f5ec (2026-08-14).
Data as JSON: /api/errors/1672b9b792658ed7.
Report an issue: GitHub.