|
@@ -57,7 +57,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
protected LanguageDriver languageDriver;
|
|
protected LanguageDriver languageDriver;
|
|
|
|
|
|
protected MapperBuilderAssistant builderAssistant;
|
|
protected MapperBuilderAssistant builderAssistant;
|
|
-
|
|
|
|
|
|
+
|
|
protected DBType dbType = DBType.MYSQL;
|
|
protected DBType dbType = DBType.MYSQL;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -74,7 +74,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
inject(configuration, builderAssistant, mapperClass);
|
|
inject(configuration, builderAssistant, mapperClass);
|
|
mapperRegistryCache.add(className);
|
|
mapperRegistryCache.add(className);
|
|
}
|
|
}
|
|
- };
|
|
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 注入单点 crudSql
|
|
* 注入单点 crudSql
|
|
@@ -117,23 +117,24 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
this.injectSelectCountSql(mapperClass, modelClass, table);
|
|
this.injectSelectCountSql(mapperClass, modelClass, table);
|
|
this.injectSelectListSql(SqlMethod.SELECT_LIST, mapperClass, modelClass, table);
|
|
this.injectSelectListSql(SqlMethod.SELECT_LIST, mapperClass, modelClass, table);
|
|
this.injectSelectListSql(SqlMethod.SELECT_PAGE, mapperClass, modelClass, table);
|
|
this.injectSelectListSql(SqlMethod.SELECT_PAGE, mapperClass, modelClass, table);
|
|
-
|
|
|
|
|
|
+
|
|
/* 自定义方法 */
|
|
/* 自定义方法 */
|
|
this.inject(configuration, builderAssistant, mapperClass, modelClass, table);
|
|
this.inject(configuration, builderAssistant, mapperClass, modelClass, table);
|
|
} else {
|
|
} else {
|
|
/**
|
|
/**
|
|
* 警告
|
|
* 警告
|
|
*/
|
|
*/
|
|
- logger.warning(String.format("%s ,Not found @TableId annotation, cannot use mybatis-plus curd method.", modelClass.toString()));
|
|
|
|
|
|
+ logger.warning(String.format("%s ,Not found @TableId annotation, cannot use mybatis-plus curd method.",
|
|
|
|
+ modelClass.toString()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 自定义方法,注入点(子类需重写该方法)
|
|
* 自定义方法,注入点(子类需重写该方法)
|
|
*/
|
|
*/
|
|
public void inject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass,
|
|
public void inject(Configuration configuration, MapperBuilderAssistant builderAssistant, Class<?> mapperClass,
|
|
Class<?> modelClass, TableInfo table) {
|
|
Class<?> modelClass, TableInfo table) {
|
|
- //to do nothing
|
|
|
|
|
|
+ // to do nothing
|
|
}
|
|
}
|
|
|
|
|
|
protected Class<?> extractModelClass(Class<?> mapperClass) {
|
|
protected Class<?> extractModelClass(Class<?> mapperClass) {
|
|
@@ -149,14 +150,14 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
Class<?> modelClass = (Class<?>) parameters[0];
|
|
Class<?> modelClass = (Class<?>) parameters[0];
|
|
return modelClass;
|
|
return modelClass;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 注入插入 SQL 语句
|
|
* 注入插入 SQL 语句
|
|
* </p>
|
|
* </p>
|
|
*
|
|
*
|
|
* @param selective
|
|
* @param selective
|
|
- * 是否选择插入
|
|
|
|
|
|
+ * 是否选择插入
|
|
* @param mapperClass
|
|
* @param mapperClass
|
|
* @param modelClass
|
|
* @param modelClass
|
|
* @param table
|
|
* @param table
|
|
@@ -204,10 +205,11 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
}
|
|
}
|
|
fieldBuilder.append("\n</trim>");
|
|
fieldBuilder.append("\n</trim>");
|
|
placeholderBuilder.append("\n</trim>");
|
|
placeholderBuilder.append("\n</trim>");
|
|
- String sql = String.format(sqlMethod.getSql(), table.getTableName(), fieldBuilder.toString(), placeholderBuilder.toString());
|
|
|
|
|
|
+ String sql = String.format(sqlMethod.getSql(), table.getTableName(), fieldBuilder.toString(),
|
|
|
|
+ placeholderBuilder.toString());
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
- this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource, keyGenerator,
|
|
|
|
- keyProperty, keyColumn);
|
|
|
|
|
|
+ this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource, keyGenerator, keyProperty,
|
|
|
|
+ keyColumn);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -250,10 +252,11 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
}
|
|
}
|
|
fieldBuilder.append("\n</trim>");
|
|
fieldBuilder.append("\n</trim>");
|
|
placeholderBuilder.append("\n</trim>");
|
|
placeholderBuilder.append("\n</trim>");
|
|
- String sql = String.format(sqlMethod.getSql(), table.getTableName(), fieldBuilder.toString(), placeholderBuilder.toString());
|
|
|
|
|
|
+ String sql = String.format(sqlMethod.getSql(), table.getTableName(), fieldBuilder.toString(),
|
|
|
|
+ placeholderBuilder.toString());
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
- this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource, keyGenerator,
|
|
|
|
- keyProperty, keyColumn);
|
|
|
|
|
|
+ this.addInsertMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource, keyGenerator, keyProperty,
|
|
|
|
+ keyColumn);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -271,7 +274,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
this.addDeleteMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource);
|
|
this.addDeleteMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 注入 map 条件删除 SQL 语句
|
|
* 注入 map 条件删除 SQL 语句
|
|
@@ -322,23 +325,22 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
* </p>
|
|
* </p>
|
|
*
|
|
*
|
|
* @param selective
|
|
* @param selective
|
|
- * 是否选择更新
|
|
|
|
|
|
+ * 是否选择更新
|
|
* @param mapperClass
|
|
* @param mapperClass
|
|
* @param modelClass
|
|
* @param modelClass
|
|
* @param table
|
|
* @param table
|
|
*/
|
|
*/
|
|
- protected void injectUpdateByIdSql( boolean selective, Class<?> mapperClass, Class<?> modelClass, TableInfo table ) {
|
|
|
|
|
|
+ protected void injectUpdateByIdSql(boolean selective, Class<?> mapperClass, Class<?> modelClass, TableInfo table) {
|
|
SqlMethod sqlMethod = SqlMethod.UPDATE_BY_ID;
|
|
SqlMethod sqlMethod = SqlMethod.UPDATE_BY_ID;
|
|
- if ( selective ) {
|
|
|
|
|
|
+ if (selective) {
|
|
sqlMethod = SqlMethod.UPDATE_SELECTIVE_BY_ID;
|
|
sqlMethod = SqlMethod.UPDATE_SELECTIVE_BY_ID;
|
|
}
|
|
}
|
|
- String sql = String.format(sqlMethod.getSql(), table.getTableName(), sqlSet(selective, table),
|
|
|
|
- table.getKeyColumn(), table.getKeyProperty());
|
|
|
|
|
|
+ String sql = String.format(sqlMethod.getSql(), table.getTableName(), sqlSet(selective, table), table.getKeyColumn(),
|
|
|
|
+ table.getKeyProperty());
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
this.addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
|
|
this.addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 注入批量更新 SQL 语句
|
|
* 注入批量更新 SQL 语句
|
|
@@ -369,7 +371,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
set.append("} THEN #{i.").append(fieldInfo.getEl()).append("}");
|
|
set.append("} THEN #{i.").append(fieldInfo.getEl()).append("}");
|
|
set.append(convertIfTag(fieldInfo, true));
|
|
set.append(convertIfTag(fieldInfo, true));
|
|
set.append("\n</foreach>");
|
|
set.append("\n</foreach>");
|
|
- set.append("\n</trim>");
|
|
|
|
|
|
+ set.append("\n</trim>");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
set.append("\n</trim>");
|
|
set.append("\n</trim>");
|
|
@@ -378,28 +380,27 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
this.addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
|
|
this.addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 注入批量更新 SQL 语句
|
|
* 注入批量更新 SQL 语句
|
|
* </p>
|
|
* </p>
|
|
*
|
|
*
|
|
* @param selective
|
|
* @param selective
|
|
- * 是否选择更新
|
|
|
|
|
|
+ * 是否选择更新
|
|
* @param mapperClass
|
|
* @param mapperClass
|
|
* @param modelClass
|
|
* @param modelClass
|
|
* @param table
|
|
* @param table
|
|
*/
|
|
*/
|
|
- protected void injectUpdateSql( boolean selective, Class<?> mapperClass, Class<?> modelClass, TableInfo table ) {
|
|
|
|
|
|
+ protected void injectUpdateSql(boolean selective, Class<?> mapperClass, Class<?> modelClass, TableInfo table) {
|
|
SqlMethod sqlMethod = SqlMethod.UPDATE;
|
|
SqlMethod sqlMethod = SqlMethod.UPDATE;
|
|
- if ( selective ) {
|
|
|
|
|
|
+ if (selective) {
|
|
sqlMethod = SqlMethod.UPDATE_SELECTIVE;
|
|
sqlMethod = SqlMethod.UPDATE_SELECTIVE;
|
|
}
|
|
}
|
|
String sql = String.format(sqlMethod.getSql(), table.getTableName(), sqlSet(selective, table), sqlWhere(table, true));
|
|
String sql = String.format(sqlMethod.getSql(), table.getTableName(), sqlSet(selective, table), sqlWhere(table, true));
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
this.addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
|
|
this.addUpdateMappedStatement(mapperClass, modelClass, sqlMethod.getMethod(), sqlSource);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -429,7 +430,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
}
|
|
}
|
|
this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, table);
|
|
this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, table);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 注入 map 查询 SQL 语句
|
|
* 注入 map 查询 SQL 语句
|
|
@@ -455,13 +456,14 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
* @param modelClass
|
|
* @param modelClass
|
|
* @param table
|
|
* @param table
|
|
*/
|
|
*/
|
|
- protected void injectSelectOneSql( Class<?> mapperClass, Class<?> modelClass, TableInfo table ) {
|
|
|
|
|
|
+ protected void injectSelectOneSql(Class<?> mapperClass, Class<?> modelClass, TableInfo table) {
|
|
SqlMethod sqlMethod = SqlMethod.SELECT_ONE;
|
|
SqlMethod sqlMethod = SqlMethod.SELECT_ONE;
|
|
- String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(table, false), table.getTableName(), sqlWhere(table, false));
|
|
|
|
|
|
+ String sql = String.format(sqlMethod.getSql(), sqlSelectColumns(table, false), table.getTableName(),
|
|
|
|
+ sqlWhere(table, false));
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, table);
|
|
this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, modelClass, table);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 注入实体查询总记录数 SQL 语句
|
|
* 注入实体查询总记录数 SQL 语句
|
|
@@ -471,13 +473,13 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
* @param modelClass
|
|
* @param modelClass
|
|
* @param table
|
|
* @param table
|
|
*/
|
|
*/
|
|
- protected void injectSelectCountSql( Class<?> mapperClass, Class<?> modelClass, TableInfo table ) {
|
|
|
|
|
|
+ protected void injectSelectCountSql(Class<?> mapperClass, Class<?> modelClass, TableInfo table) {
|
|
SqlMethod sqlMethod = SqlMethod.SELECT_COUNT;
|
|
SqlMethod sqlMethod = SqlMethod.SELECT_COUNT;
|
|
String sql = String.format(sqlMethod.getSql(), table.getTableName(), sqlWhere(table, true));
|
|
String sql = String.format(sqlMethod.getSql(), table.getTableName(), sqlWhere(table, true));
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
|
this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Integer.class, null);
|
|
this.addSelectMappedStatement(mapperClass, sqlMethod.getMethod(), sqlSource, Integer.class, null);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 注入实体查询记录列表 SQL 语句
|
|
* 注入实体查询记录列表 SQL 语句
|
|
@@ -514,27 +516,27 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
* </p>
|
|
* </p>
|
|
*
|
|
*
|
|
* @param selective
|
|
* @param selective
|
|
- * 是否选择更新
|
|
|
|
|
|
+ * 是否选择更新
|
|
* @param table
|
|
* @param table
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- protected String sqlSet( boolean selective, TableInfo table ) {
|
|
|
|
|
|
+ protected String sqlSet(boolean selective, TableInfo table) {
|
|
StringBuilder set = new StringBuilder();
|
|
StringBuilder set = new StringBuilder();
|
|
set.append("<trim prefix=\"SET\" suffixOverrides=\",\">");
|
|
set.append("<trim prefix=\"SET\" suffixOverrides=\",\">");
|
|
List<TableFieldInfo> fieldList = table.getFieldList();
|
|
List<TableFieldInfo> fieldList = table.getFieldList();
|
|
- for ( TableFieldInfo fieldInfo : fieldList ) {
|
|
|
|
- if ( selective ) {
|
|
|
|
|
|
+ for (TableFieldInfo fieldInfo : fieldList) {
|
|
|
|
+ if (selective) {
|
|
set.append(convertIfTag(fieldInfo, "et.", false));
|
|
set.append(convertIfTag(fieldInfo, "et.", false));
|
|
}
|
|
}
|
|
set.append(fieldInfo.getColumn()).append("=#{et.").append(fieldInfo.getEl()).append("},");
|
|
set.append(fieldInfo.getColumn()).append("=#{et.").append(fieldInfo.getEl()).append("},");
|
|
- if ( selective ) {
|
|
|
|
|
|
+ if (selective) {
|
|
set.append(convertIfTag(fieldInfo, true));
|
|
set.append(convertIfTag(fieldInfo, true));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
set.append("\n</trim>");
|
|
set.append("\n</trim>");
|
|
return set.toString();
|
|
return set.toString();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* SQL 查询所有表字段
|
|
* SQL 查询所有表字段
|
|
@@ -595,12 +597,12 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
*
|
|
*
|
|
* @param table
|
|
* @param table
|
|
* @param space
|
|
* @param space
|
|
- * 是否为空判断
|
|
|
|
|
|
+ * 是否为空判断
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected String sqlWhere(TableInfo table, boolean space) {
|
|
protected String sqlWhere(TableInfo table, boolean space) {
|
|
StringBuilder where = new StringBuilder();
|
|
StringBuilder where = new StringBuilder();
|
|
- if ( space ) {
|
|
|
|
|
|
+ if (space) {
|
|
where.append("\n<if test=\"ew!=null\">");
|
|
where.append("\n<if test=\"ew!=null\">");
|
|
}
|
|
}
|
|
where.append("\n<where>");
|
|
where.append("\n<where>");
|
|
@@ -614,12 +616,12 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
where.append(convertIfTag(fieldInfo, true));
|
|
where.append(convertIfTag(fieldInfo, true));
|
|
}
|
|
}
|
|
where.append("\n</where>");
|
|
where.append("\n</where>");
|
|
- if ( space ) {
|
|
|
|
|
|
+ if (space) {
|
|
where.append("\n</if>");
|
|
where.append("\n</if>");
|
|
}
|
|
}
|
|
return where.toString();
|
|
return where.toString();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* SQL map 查询条件
|
|
* SQL map 查询条件
|
|
@@ -629,7 +631,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
StringBuilder where = new StringBuilder();
|
|
StringBuilder where = new StringBuilder();
|
|
where.append("\n<foreach collection=\"cm.keys\" item=\"k\" separator=\"AND\"> ");
|
|
where.append("\n<foreach collection=\"cm.keys\" item=\"k\" separator=\"AND\"> ");
|
|
where.append("\n${k}=#{cm[${k}]}");
|
|
where.append("\n${k}=#{cm[${k}]}");
|
|
- where.append("\n</foreach>");
|
|
|
|
|
|
+ where.append("\n</foreach>");
|
|
return where.toString();
|
|
return where.toString();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -639,11 +641,11 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
* </p>
|
|
* </p>
|
|
*
|
|
*
|
|
* @param fieldInfo
|
|
* @param fieldInfo
|
|
- * 字段信息
|
|
|
|
|
|
+ * 字段信息
|
|
* @param prefix
|
|
* @param prefix
|
|
- * 条件前缀
|
|
|
|
|
|
+ * 条件前缀
|
|
* @param colse
|
|
* @param colse
|
|
- * 是否闭合标签
|
|
|
|
|
|
+ * 是否闭合标签
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected String convertIfTag(TableFieldInfo fieldInfo, String prefix, boolean colse) {
|
|
protected String convertIfTag(TableFieldInfo fieldInfo, String prefix, boolean colse) {
|
|
@@ -669,7 +671,7 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
}
|
|
}
|
|
return "";
|
|
return "";
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
protected String convertIfTag(TableFieldInfo fieldInfo, boolean colse) {
|
|
protected String convertIfTag(TableFieldInfo fieldInfo, boolean colse) {
|
|
return convertIfTag(fieldInfo, null, colse);
|
|
return convertIfTag(fieldInfo, null, colse);
|
|
}
|
|
}
|
|
@@ -677,46 +679,45 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
/*
|
|
/*
|
|
* 查询
|
|
* 查询
|
|
*/
|
|
*/
|
|
- public MappedStatement addSelectMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource,
|
|
|
|
- Class<?> resultType, TableInfo table) {
|
|
|
|
|
|
+ public MappedStatement addSelectMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource, Class<?> resultType,
|
|
|
|
+ TableInfo table) {
|
|
if (null != table) {
|
|
if (null != table) {
|
|
String resultMap = table.getResultMap();
|
|
String resultMap = table.getResultMap();
|
|
if (null != resultMap) {
|
|
if (null != resultMap) {
|
|
/* 返回 resultMap 映射结果集 */
|
|
/* 返回 resultMap 映射结果集 */
|
|
- return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, resultMap,
|
|
|
|
- null, new NoKeyGenerator(), null, null);
|
|
|
|
|
|
+ return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, resultMap, null,
|
|
|
|
+ new NoKeyGenerator(), null, null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/* 普通查询 */
|
|
/* 普通查询 */
|
|
- return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, null,
|
|
|
|
- resultType, new NoKeyGenerator(), null, null);
|
|
|
|
|
|
+ return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.SELECT, null, null, resultType,
|
|
|
|
+ new NoKeyGenerator(), null, null);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
* 插入
|
|
* 插入
|
|
*/
|
|
*/
|
|
- public MappedStatement addInsertMappedStatement(Class<?> mapperClass, Class<?> modelClass, String id,
|
|
|
|
- SqlSource sqlSource, KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
|
|
|
|
- return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.INSERT, modelClass, null,
|
|
|
|
- Integer.class, keyGenerator, keyProperty, keyColumn);
|
|
|
|
|
|
+ public MappedStatement addInsertMappedStatement(Class<?> mapperClass, Class<?> modelClass, String id, SqlSource sqlSource,
|
|
|
|
+ KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
|
|
|
|
+ return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.INSERT, modelClass, null, Integer.class,
|
|
|
|
+ keyGenerator, keyProperty, keyColumn);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* 删除
|
|
* 删除
|
|
*/
|
|
*/
|
|
public MappedStatement addDeleteMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource) {
|
|
public MappedStatement addDeleteMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource) {
|
|
- return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.DELETE, null, null,
|
|
|
|
- Integer.class, new NoKeyGenerator(), null, null);
|
|
|
|
|
|
+ return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.DELETE, null, null, Integer.class,
|
|
|
|
+ new NoKeyGenerator(), null, null);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
* 更新
|
|
* 更新
|
|
*/
|
|
*/
|
|
- public MappedStatement addUpdateMappedStatement(Class<?> mapperClass, Class<?> modelClass, String id,
|
|
|
|
- SqlSource sqlSource) {
|
|
|
|
- return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.UPDATE, modelClass, null,
|
|
|
|
- Integer.class, new NoKeyGenerator(), null, null);
|
|
|
|
|
|
+ public MappedStatement addUpdateMappedStatement(Class<?> mapperClass, Class<?> modelClass, String id, SqlSource sqlSource) {
|
|
|
|
+ return this.addMappedStatement(mapperClass, id, sqlSource, SqlCommandType.UPDATE, modelClass, null, Integer.class,
|
|
|
|
+ new NoKeyGenerator(), null, null);
|
|
}
|
|
}
|
|
|
|
|
|
public MappedStatement addMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource,
|
|
public MappedStatement addMappedStatement(Class<?> mapperClass, String id, SqlSource sqlSource,
|
|
@@ -724,7 +725,8 @@ public class AutoSqlInjector implements ISqlInjector {
|
|
KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
|
|
KeyGenerator keyGenerator, String keyProperty, String keyColumn) {
|
|
String statementName = mapperClass.getName() + "." + id;
|
|
String statementName = mapperClass.getName() + "." + id;
|
|
if (configuration.hasStatement(statementName)) {
|
|
if (configuration.hasStatement(statementName)) {
|
|
- System.err.println("{" + statementName + "} Has been loaded by XML or SqlProvider, ignoring the injection of the SQL.");
|
|
|
|
|
|
+ System.err.println("{" + statementName
|
|
|
|
+ + "} Has been loaded by XML or SqlProvider, ignoring the injection of the SQL.");
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
/* 缓存逻辑处理 */
|
|
/* 缓存逻辑处理 */
|