hibernate 也可以像 mybatis 一样配置maperr.xml文件 是怎么做到的

it2025-12-30  3

public class SqlMappingAnalyzer { private static final Logger log = LoggerFactory.getLogger(SqlMappingAnalyzer.class); /** * 单例 */ private static SqlMappingAnalyzer analyzer = null; /** * 与Web容器生命周期相同SQL存储对象 */ private Map<String, Map<String, String>> map = new HashMap<String, Map<String, String>>(); /** * 待分析的所有SQL映射文件 */ private List<Document> sqlDocs = Collections.emptyList(); /** sql 文件的命名规范 */ private final static String pattern = "classpath*:com/ssh/**/*-sql.xml"; private final static String fileSub = "com/ssh/"; private SqlMappingAnalyzer() { // 每一份xml文件都会被解析成为一个Document对象 this.sqlDocs = this.getSqlDocs(); if (!sqlDocs.isEmpty()) { // 分析映射文件 this.analyzing(); }else { log.warn("没有找到一个SQL自定义文件!"); } } private List<Document> getSqlDocs() { L
最新回复(0)