{"record":{"id":"e7c8a136fb539412","repo":"jeecgboot/JeecgBoot","slug":"daoformat-minidao","errorCode":null,"errorMessage":"DaoFormat 是 minidao 保留关键字，不允许使用 ，请更改参数定义！","messagePattern":"DaoFormat 是 minidao 保留关键字，不允许使用 ，请更改参数定义！","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/dynamic/db/FreemarkerParseFactory.java","lineNumber":99,"sourceCode":"            return false;\n        }\n        return true;\n    }\n\n    /**\n     * 解析ftl模板\n     *\n     * @param tplName 模板名\n     * @param paras   参数\n     * @return\n     */\n    public static String parseTemplate(String tplName, Map<String, Object> paras) {\n        try {\n            log.debug(\" minidao sql templdate : \" + tplName);\n            StringWriter swriter = new StringWriter();\n            Template mytpl = TPL_CONFIG.getTemplate(tplName, ENCODE);\n            if (paras.containsKey(MINI_DAO_FORMAT)) {\n                throw new RuntimeException(\"DaoFormat 是 minidao 保留关键字，不允许使用 ，请更改参数定义！\");\n            }\n            paras.put(MINI_DAO_FORMAT, new SimpleFormat());\n            mytpl.process(paras, swriter);\n            String sql = getSqlText(swriter.toString());\n            paras.remove(MINI_DAO_FORMAT);\n            return sql;\n        } catch (Exception e) {\n            log.error(e.getMessage(), e.fillInStackTrace());\n            log.error(\"发送一次的模板key:{ \" + tplName + \" }\");\n            //System.err.println(e.getMessage());\n            //System.err.println(\"模板名:{ \"+ tplName +\" }\");\n            throw new RuntimeException(\"解析SQL模板异常\");\n        }\n    }\n\n    /**\n     * 解析ftl\n     *","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/jeecgboot/JeecgBoot/blob/96fb33f5ec68516da0b0147da06b2eb0419e063a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/dynamic/db/FreemarkerParseFactory.java#L81-L117","documentation":"Thrown by FreemarkerParseFactory.parseTemplate when the caller's parameter map already contains the key 'DaoFormat' (MINI_DAO_FORMAT constant). The method needs to inject its own SimpleFormat helper under that exact key, so a collision is treated as a programming error. It is wrapped/rethrown as a generic '解析SQL模板异常' RuntimeException.","triggerScenarios":"A minidao DAO method receives a parameter Map that was built with a key literally named 'DaoFormat', or a copy/merge of two maps accidentally carried the reserved key over. Common in custom minidao SQL templates and report SQL templating.","commonSituations":"Developer named a real business field 'daoFormat'/'DaoFormat'; a generic map-merge utility duplicated keys across parameter sources; a template param builder reused a static map without clearing.","solutions":["Rename the conflicting business parameter to something other than 'DaoFormat'.","Build a fresh HashMap for each minidao call instead of reusing/mutating a shared map.","Strip the reserved key defensively before calling parseTemplate: paras.remove(\"DaoFormat\").","Document the reserved key in your DAO layer so future params avoid it."],"exampleFix":"// before\nMap<String,Object> paras = new HashMap<>();\nparas.put(\"DaoFormat\", \"report\"); // reserved!\nFreemarkerParseFactory.parseTemplate(\"userList.ftl\", paras);\n\n// after\nparas.put(\"format\", \"report\");\nFreemarkerParseFactory.parseTemplate(\"userList.ftl\", paras);","handlingStrategy":"validation","validationCode":"if (paras.containsKey(\"DaoFormat\")) paras.remove(\"DaoFormat\");\nFreemarkerParseFactory.parseTemplate(tplName, paras);","typeGuard":"public static boolean noReservedKeys(Map<String,Object> p){ return p == null || !p.containsKey(\"DaoFormat\"); }","tryCatchPattern":"try { FreemarkerParseFactory.parseTemplate(t, p); }\ncatch (RuntimeException e) { log.error(\"template {} failed: {}\", t, e.getMessage()); }","preventionTips":["Namespace business param keys to avoid minidao internals.","Build a fresh map per DAO call.","Document reserved keys for DAO authors."],"tags":["freemarker","minidao","template","configuration","jeecg-boot"],"backgroundTag":null,"analyzedSha":"96fb33f5ec68516da0b0147da06b2eb0419e063a","analyzedAt":"2026-08-14T00:04:16.786Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}