Java tutorial
/** * Copyright (c) 2011-2014, hubin (jobob@qq.com). * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.tj.mybatisplus; import java.util.logging.Logger; import org.apache.ibatis.mapping.MappedStatement; import org.apache.ibatis.scripting.LanguageDriver; import org.apache.ibatis.session.Configuration; import com.tj.mybatisplus.mapper.DBType; /** * <p> * replace default Configuration class * </p> * * @author hubin * @Date 2016-01-23 */ public class MybatisConfiguration extends Configuration { protected final Logger logger = Logger.getLogger("MybatisConfiguration"); /** * ? MySql */ public static DBType DB_TYPE = DBType.MYSQL; /** * ? */ public MybatisConfiguration() { System.err.println("mybatis-plus init success."); } /** * <p> * MybatisPlus SQL ? * </p> * 1?XMLSQL<br> * 2?sqlProviderSQL<br> * 3?xmlSql sqlProvider???SQL<br> * <br> * ?SQLxmlSql > sqlProvider > curdSql <br> */ @Override public void addMappedStatement(MappedStatement ms) { logger.fine(" addMappedStatement: " + ms.getId()); if (this.mappedStatements.containsKey(ms.getId())) { /* * xml mapperSqlProvider? */ logger.severe("mapper[" + ms.getId() + "] is ignored, because it's exists, maybe from xml file"); return; } super.addMappedStatement(ms); } @Override public void setDefaultScriptingLanguage(Class<?> driver) { if (driver == null) { /* driver */ driver = MybatisXMLLanguageDriver.class; } super.setDefaultScriptingLanguage(driver); } @Override public LanguageDriver getDefaultScriptingLanuageInstance() { /* driver */ return languageRegistry.getDriver(MybatisXMLLanguageDriver.class); } }