|
@@ -15,17 +15,19 @@
|
|
|
*/
|
|
|
package com.baomidou.mybatisplus.mapper;
|
|
|
|
|
|
-import java.lang.reflect.ParameterizedType;
|
|
|
-import java.lang.reflect.Type;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
-import java.util.logging.Logger;
|
|
|
-
|
|
|
+import com.baomidou.mybatisplus.MybatisConfiguration;
|
|
|
+import com.baomidou.mybatisplus.annotations.FieldStrategy;
|
|
|
+import com.baomidou.mybatisplus.annotations.IdType;
|
|
|
+import com.baomidou.mybatisplus.toolkit.SqlReservedWords;
|
|
|
+import com.baomidou.mybatisplus.toolkit.TableFieldInfo;
|
|
|
+import com.baomidou.mybatisplus.toolkit.TableInfo;
|
|
|
+import com.baomidou.mybatisplus.toolkit.TableInfoHelper;
|
|
|
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
|
|
import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
|
|
|
import org.apache.ibatis.executor.keygen.KeyGenerator;
|
|
|
import org.apache.ibatis.executor.keygen.NoKeyGenerator;
|
|
|
+import org.apache.ibatis.logging.Log;
|
|
|
+import org.apache.ibatis.logging.LogFactory;
|
|
|
import org.apache.ibatis.mapping.MappedStatement;
|
|
|
import org.apache.ibatis.mapping.SqlCommandType;
|
|
|
import org.apache.ibatis.mapping.SqlSource;
|
|
@@ -34,14 +36,11 @@ import org.apache.ibatis.scripting.LanguageDriver;
|
|
|
import org.apache.ibatis.scripting.defaults.RawSqlSource;
|
|
|
import org.apache.ibatis.session.Configuration;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.MybatisConfiguration;
|
|
|
-import com.baomidou.mybatisplus.annotations.FieldStrategy;
|
|
|
-import com.baomidou.mybatisplus.annotations.IdType;
|
|
|
-import com.baomidou.mybatisplus.toolkit.SqlReservedWords;
|
|
|
-import com.baomidou.mybatisplus.toolkit.TableFieldInfo;
|
|
|
-import com.baomidou.mybatisplus.toolkit.TableInfo;
|
|
|
-import com.baomidou.mybatisplus.toolkit.TableInfoHelper;
|
|
|
-
|
|
|
+import java.lang.reflect.ParameterizedType;
|
|
|
+import java.lang.reflect.Type;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -52,7 +51,8 @@ import com.baomidou.mybatisplus.toolkit.TableInfoHelper;
|
|
|
* @Date 2016-09-09
|
|
|
*/
|
|
|
public class AutoSqlInjector implements ISqlInjector {
|
|
|
- protected static final Logger logger = Logger.getLogger("AutoSqlInjector");
|
|
|
+
|
|
|
+ private static final Log logger = LogFactory.getLog(AutoSqlInjector.class);
|
|
|
|
|
|
protected Configuration configuration;
|
|
|
|
|
@@ -126,7 +126,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
|
/**
|
|
|
* 警告
|
|
|
*/
|
|
|
- logger.warning(String.format("%s ,Not found @TableId annotation, cannot use mybatis-plus curd method.",
|
|
|
+ logger.warn(String.format("%s ,Not found @TableId annotation, cannot use mybatis-plus curd method.",
|
|
|
modelClass.toString()));
|
|
|
}
|
|
|
}
|
|
@@ -135,7 +135,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
|
* 自定义方法,注入点(子类需重写该方法)
|
|
|
*/
|
|
|
public void inject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass,
|
|
|
- Class<?> modelClass, TableInfo table) {
|
|
|
+ Class<?> modelClass, TableInfo table) {
|
|
|
// to do nothing
|
|
|
}
|
|
|
|
|
@@ -612,7 +612,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
|
* 查询
|
|
|
*/
|
|
|
public MappedStatement addSelectMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource, Class<?> resultType,
|
|
|
- TableInfo table) {
|
|
|
+ TableInfo table) {
|
|
|
if (null != table) {
|
|
|
String resultMap = table.getResultMap();
|
|
|
if (null != resultMap) {
|
|
@@ -631,7 +631,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
|
* 插入
|
|
|
*/
|
|
|
public MappedStatement addInsertMappedStatement(Class<?> mapperClass, Class<?> modelClass, String id, SqlSource sqlSource,
|
|
|
- KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
|
|
|
+ KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
|
|
|
return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.INSERT, modelClass, null, Integer.class,
|
|
|
keyGenerator, keyProperty, keyColumn);
|
|
|
}
|
|
@@ -653,8 +653,8 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
|
}
|
|
|
|
|
|
public MappedStatement addMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource,
|
|
|
- SqlCommandType sqlCommandType, Class<?> parameterClass, String resultMap, Class<?> resultType,
|
|
|
- KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
|
|
|
+ SqlCommandType sqlCommandType, Class<?> parameterClass, String resultMap, Class<?> resultType,
|
|
|
+ KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
|
|
|
String statementName = mapperClass.getName() + "." + id;
|
|
|
if (configuration.hasStatement(statementName)) {
|
|
|
System.err.println("{" + statementName
|