modifyAttrs = new LinkedHashSet<>(rows.get(0).obtainModifyAttrs());
- rows.forEach(row -> RowCPI.keepModifyAttrs(row, modifyAttrs));
+ rows.forEach(row -> row.prepareAttrs(modifyAttrs));
Object[] values = new Object[]{};
@@ -245,6 +245,29 @@ public class RowSqlProvider {
return DialectFactory.getDialect().forUpdateEntity(tableInfo, entity, false);
}
+ /**
+ * 执行类似 update table set field=field+1 where ... 的场景
+ *
+ * @param params
+ * @return sql
+ * @see RowMapper#updateNumberAddByQuery(String, String, Number, QueryWrapper)
+ */
+ public static String updateNumberAddByQuery(Map params) {
+
+ QueryWrapper queryWrapper = ProviderUtil.getQueryWrapper(params);
+
+ String tableName = ProviderUtil.getTableName(params);
+ String fieldName = ProviderUtil.getFieldName(params);
+ Number value = (Number) ProviderUtil.getValue(params);
+
+
+ Object[] queryParams = CPI.getValueArray(queryWrapper);
+
+ ProviderUtil.setSqlArgs(params, queryParams);
+
+ return DialectFactory.getDialect().forUpdateNumberAddByQuery(tableName, fieldName, value, queryWrapper);
+ }
+
/**
* selectOneById 的 sql 构建
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/ArithmeticQueryColumn.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/ArithmeticQueryColumn.java
new file mode 100644
index 00000000..7d160fed
--- /dev/null
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/ArithmeticQueryColumn.java
@@ -0,0 +1,133 @@
+/**
+ * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.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.mybatisflex.core.query;
+
+import com.mybatisflex.core.dialect.IDialect;
+import com.mybatisflex.core.util.StringUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ArithmeticQueryColumn extends QueryColumn {
+
+ private List arithmeticInfos;
+
+ public ArithmeticQueryColumn(Object value) {
+ arithmeticInfos = new ArrayList<>();
+ arithmeticInfos.add(new ArithmeticInfo(value));
+ }
+
+ @Override
+ public QueryColumn add(QueryColumn queryColumn) {
+ arithmeticInfos.add(new ArithmeticInfo(" + ", queryColumn));
+ return this;
+ }
+
+ @Override
+ public QueryColumn add(Number number) {
+ arithmeticInfos.add(new ArithmeticInfo(" + ", number));
+ return this;
+ }
+
+ @Override
+ public QueryColumn subtract(QueryColumn queryColumn) {
+ arithmeticInfos.add(new ArithmeticInfo(" - ", queryColumn));
+ return this;
+ }
+
+ @Override
+ public QueryColumn subtract(Number number) {
+ arithmeticInfos.add(new ArithmeticInfo(" - ", number));
+ return this;
+ }
+
+ @Override
+ public QueryColumn multiply(QueryColumn queryColumn) {
+ arithmeticInfos.add(new ArithmeticInfo(" * ", queryColumn));
+ return this;
+ }
+
+ @Override
+ public QueryColumn multiply(Number number) {
+ arithmeticInfos.add(new ArithmeticInfo(" * ", number));
+ return this;
+ }
+
+ @Override
+ public QueryColumn divide(QueryColumn queryColumn) {
+ arithmeticInfos.add(new ArithmeticInfo(" / ", queryColumn));
+ return this;
+ }
+
+ @Override
+ public QueryColumn divide(Number number) {
+ arithmeticInfos.add(new ArithmeticInfo(" / ", number));
+ return this;
+ }
+
+ @Override
+ public QueryColumn as(String alias) {
+ this.alias = alias;
+ return this;
+ }
+
+ @Override
+ String toSelectSql(List queryTables, IDialect dialect) {
+ StringBuilder sql = new StringBuilder();
+ for (int i = 0; i < arithmeticInfos.size(); i++) {
+ sql.append(arithmeticInfos.get(i).toSql(queryTables, dialect, i));
+ }
+ if (StringUtil.isNotBlank(alias)) {
+ return "(" + sql + ") AS " + dialect.wrap(alias);
+ }
+ return sql.toString();
+ }
+
+
+ @Override
+ String toConditionSql(List queryTables, IDialect dialect) {
+ StringBuilder sql = new StringBuilder();
+ for (int i = 0; i < arithmeticInfos.size(); i++) {
+ sql.append(arithmeticInfos.get(i).toSql(queryTables, dialect, i));
+ }
+ return "(" + sql + ")";
+ }
+
+
+ static class ArithmeticInfo {
+ private String symbol;
+ private Object value;
+
+ public ArithmeticInfo(Object value) {
+ this.value = value;
+ }
+
+ public ArithmeticInfo(String symbol, Object value) {
+ this.symbol = symbol;
+ this.value = value;
+ }
+
+ private String toSql(List queryTables, IDialect dialect, int index) {
+ String valueSql;
+ if (value instanceof QueryColumn) {
+ valueSql = ((QueryColumn) value).toConditionSql(queryTables, dialect);
+ } else {
+ valueSql = String.valueOf(value);
+ }
+ return index == 0 ? valueSql : symbol + valueSql;
+ }
+ }
+}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/FunctionQueryColumn.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/FunctionQueryColumn.java
index d580fa2e..37507872 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/FunctionQueryColumn.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/FunctionQueryColumn.java
@@ -60,7 +60,7 @@ public class FunctionQueryColumn extends QueryColumn implements HasParamsColumn
@Override
public Object[] getParamValues() {
- if (column instanceof HasParamsColumn){
+ if (column instanceof HasParamsColumn) {
return ((HasParamsColumn) column).getParamValues();
}
return WrapperUtil.NULL_PARA_ARRAY;
@@ -69,7 +69,7 @@ public class FunctionQueryColumn extends QueryColumn implements HasParamsColumn
@Override
public String toSelectSql(List queryTables, IDialect dialect) {
String sql = column.toSelectSql(queryTables, dialect);
- return StringUtil.isBlank(sql) ? "" : fnName + "(" + sql + ")" + WrapperUtil.buildAsAlias(alias);
+ return StringUtil.isBlank(sql) ? "" : fnName + "(" + sql + ")" + WrapperUtil.buildAsAlias(alias, dialect);
}
@Override
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryColumn.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryColumn.java
index 2d5f10b3..9bf82fa0 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryColumn.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryColumn.java
@@ -224,7 +224,7 @@ public class QueryColumn implements Serializable {
*/
public QueryCondition in(Object... arrays) {
//忽略 QueryWrapper.in("name", null) 的情况
- if (arrays == null || arrays.length == 0 || (arrays.length == 1 && arrays[0] == null)) {
+ if (arrays == null || arrays.length == 0 || (arrays.length == 1 && arrays[0] == null)) {
return QueryCondition.createEmpty();
}
return QueryCondition.create(this, QueryCondition.LOGIC_IN, arrays);
@@ -262,7 +262,7 @@ public class QueryColumn implements Serializable {
*/
public QueryCondition notIn(Object... arrays) {
//忽略 QueryWrapper.notIn("name", null) 的情况
- if (arrays == null || arrays.length == 0 || (arrays.length == 1 && arrays[0] == null)) {
+ if (arrays == null || arrays.length == 0 || (arrays.length == 1 && arrays[0] == null)) {
return QueryCondition.createEmpty();
}
return QueryCondition.create(this, QueryCondition.LOGIC_NOT_IN, arrays);
@@ -324,6 +324,40 @@ public class QueryColumn implements Serializable {
}
+ // 运算 加减乘除 + - * /
+ public QueryColumn add(QueryColumn queryColumn) {
+ return new ArithmeticQueryColumn(this).add(queryColumn);
+ }
+
+ public QueryColumn add(Number number) {
+ return new ArithmeticQueryColumn(this).add(number);
+ }
+
+ public QueryColumn subtract(QueryColumn queryColumn) {
+ return new ArithmeticQueryColumn(this).subtract(queryColumn);
+ }
+
+ public QueryColumn subtract(Number number) {
+ return new ArithmeticQueryColumn(this).subtract(number);
+ }
+
+ public QueryColumn multiply(QueryColumn queryColumn) {
+ return new ArithmeticQueryColumn(this).multiply(queryColumn);
+ }
+
+ public QueryColumn multiply(Number number) {
+ return new ArithmeticQueryColumn(this).multiply(number);
+ }
+
+ public QueryColumn divide(QueryColumn queryColumn) {
+ return new ArithmeticQueryColumn(this).divide(queryColumn);
+ }
+
+ public QueryColumn divide(Number number) {
+ return new ArithmeticQueryColumn(this).divide(number);
+ }
+
+
protected String wrap(IDialect dialect, String table, String column) {
if (StringUtil.isNotBlank(table)) {
return dialect.wrap(table) + "." + dialect.wrap(column);
@@ -340,7 +374,7 @@ public class QueryColumn implements Serializable {
String toSelectSql(List queryTables, IDialect dialect) {
String tableName = WrapperUtil.getColumnTableName(queryTables, table);
- return wrap(dialect, tableName, name) + WrapperUtil.buildAsAlias(dialect.wrap(alias));
+ return wrap(dialect, tableName, name) + WrapperUtil.buildAsAlias(alias, dialect);
}
@Override
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryTable.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryTable.java
index c8d14905..2268fcb1 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryTable.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/QueryTable.java
@@ -63,7 +63,7 @@ public class QueryTable implements Serializable {
}
public String toSql(IDialect dialect) {
- return dialect.wrap(name) + WrapperUtil.buildAsAlias(dialect.wrap(alias));
+ return dialect.wrap(name) + WrapperUtil.buildAsAlias(alias, dialect);
}
@Override
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/StringFunctionQueryColumn.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/StringFunctionQueryColumn.java
index 8fb5cbd6..778eeba1 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/StringFunctionQueryColumn.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/StringFunctionQueryColumn.java
@@ -30,7 +30,7 @@ public class StringFunctionQueryColumn extends QueryColumn {
protected String fnName;
protected List params;
- public StringFunctionQueryColumn(String fnName, String ...params) {
+ public StringFunctionQueryColumn(String fnName, String... params) {
SqlUtil.keepColumnSafely(fnName);
this.fnName = fnName;
this.params = Arrays.asList(params);
@@ -56,13 +56,13 @@ public class StringFunctionQueryColumn extends QueryColumn {
@Override
public String toSelectSql(List queryTables, IDialect dialect) {
- String sql = StringUtil.join(", ",params);
- return StringUtil.isBlank(sql) ? "" : fnName + "(" + sql + ")" + WrapperUtil.buildAsAlias(alias);
+ String sql = StringUtil.join(", ", params);
+ return StringUtil.isBlank(sql) ? "" : fnName + "(" + sql + ")" + WrapperUtil.buildAsAlias(alias, dialect);
}
@Override
String toConditionSql(List queryTables, IDialect dialect) {
- String sql = StringUtil.join(", ",params);
+ String sql = StringUtil.join(", ", params);
return StringUtil.isBlank(sql) ? "" : fnName + "(" + sql + ")";
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/WrapperUtil.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/WrapperUtil.java
index ae9d27ba..cd089694 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/WrapperUtil.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/WrapperUtil.java
@@ -16,6 +16,7 @@
package com.mybatisflex.core.query;
+import com.mybatisflex.core.dialect.IDialect;
import com.mybatisflex.core.util.ClassUtil;
import com.mybatisflex.core.util.CollectionUtil;
import com.mybatisflex.core.util.EnumWrapper;
@@ -30,8 +31,8 @@ import java.util.List;
class WrapperUtil {
- static String buildAsAlias(String alias) {
- return StringUtil.isBlank(alias) ? "" : " AS " + alias;
+ static String buildAsAlias(String alias, IDialect dialect) {
+ return StringUtil.isBlank(alias) ? "" : " AS " + dialect.wrap(alias);
}
static final Object[] NULL_PARA_ARRAY = new Object[0];
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Db.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Db.java
index c228ddd1..41fa7f58 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Db.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Db.java
@@ -286,6 +286,7 @@ public class Db {
})).sum();
}
+
/**
* 根据主键来批量更新数据
*
@@ -297,6 +298,11 @@ public class Db {
}
+ public static int updateNumberAddByQuery(String tableName, String fieldName, Number value, QueryWrapper queryWrapper){
+ return invoker().updateNumberAddByQuery(tableName, fieldName, value, queryWrapper);
+ }
+
+
/**
* 批量执行工具方法
*
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Row.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Row.java
index 514bf14d..d1d8248e 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Row.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/Row.java
@@ -316,8 +316,29 @@ public class Row extends LinkedHashMap implements ModifyAttrsRec
return ret;
}
+ public void prepareAttrsByKeySet(){
+ this.modifyAttrs.clear();
+ this.modifyAttrs.addAll(keySet());
- void keepModifyAttrs(Collection attrs) {
+ if (this.primaryKeys != null){
+ for (RowKey primaryKey : primaryKeys) {
+ this.modifyAttrs.removeIf(s -> s.equalsIgnoreCase(primaryKey.getKeyColumn()));
+ }
+ }
+ }
+
+
+ public void prepareAttrsByKeySet(RowKey ... primaryKeys){
+ this.modifyAttrs.clear();
+ this.modifyAttrs.addAll(keySet());
+ this.primaryKeys = primaryKeys;
+
+ for (RowKey primaryKey : primaryKeys) {
+ this.modifyAttrs.removeIf(s -> s.equalsIgnoreCase(primaryKey.getKeyColumn()));
+ }
+ }
+
+ public void prepareAttrs(Collection attrs) {
if (attrs == null) {
throw new NullPointerException("attrs is null.");
}
@@ -325,6 +346,17 @@ public class Row extends LinkedHashMap implements ModifyAttrsRec
modifyAttrs.addAll(attrs);
}
+ public RowKey[] getPrimaryKeys() {
+ return primaryKeys;
+ }
+
+ public void setPrimaryKeys(RowKey... primaryKeys) {
+ this.primaryKeys = primaryKeys;
+ for (RowKey primaryKey : primaryKeys) {
+ this.modifyAttrs.removeIf(s -> s.equalsIgnoreCase(primaryKey.getKeyColumn()));
+ }
+ }
+
/**
* 获取修改的值,值需要保持顺序,返回的内容不包含主键的值
*/
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowCPI.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowCPI.java
index 5001747c..5ab652d4 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowCPI.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowCPI.java
@@ -15,17 +15,11 @@
*/
package com.mybatisflex.core.row;
-import java.util.Collection;
-
/**
* cross package invoker
*/
public class RowCPI {
- public static void keepModifyAttrs(Row row, Collection attrs) {
- row.keepModifyAttrs(attrs);
- }
-
public static Object[] obtainModifyValues(Row row) {
return row.obtainModifyValues();
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowKey.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowKey.java
index 21b01fca..ad6b7f94 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowKey.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowKey.java
@@ -16,6 +16,7 @@
package com.mybatisflex.core.row;
import com.mybatisflex.annotation.KeyType;
+import com.mybatisflex.core.keygen.KeyGenerators;
import com.mybatisflex.core.util.SqlUtil;
/**
@@ -26,12 +27,22 @@ public class RowKey {
/**
* 自增 ID
*/
- public static final RowKey ID_AUTO = RowKey.of("id", KeyType.Auto, null, false);
+ public static final RowKey AUTO = RowKey.of("id", KeyType.Auto, null, false);
/**
* UUID 的 ID
*/
- public static final RowKey ID_UUID = RowKey.of("id", KeyType.Generator, "uuid", true);
+ public static final RowKey UUID = RowKey.of("id", KeyType.Generator, KeyGenerators.uuid, true);
+
+ /**
+ * flexId
+ */
+ public static final RowKey FLEX_ID = RowKey.of("id", KeyType.Generator, KeyGenerators.flexId, true);
+
+ /**
+ * snowFlakeId
+ */
+ public static final RowKey SNOW_FLAKE_ID = RowKey.of("id", KeyType.Generator, KeyGenerators.snowFlakeId, true);
public static RowKey of(String keyColumn) {
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowMapper.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowMapper.java
index ea85985f..4f69b538 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowMapper.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowMapper.java
@@ -198,6 +198,20 @@ public interface RowMapper {
@UpdateProvider(value = RowSqlProvider.class, method = "updateEntity")
int updateEntity(@Param(FlexConsts.ENTITY) Object entity);
+
+ /**
+ * 执行类似 update table set field=field+1 where ... 的场景
+ *
+ * @param fieldName 字段名
+ * @param value 值( >=0 加,小于 0 减)
+ * @param queryWrapper 条件
+ * @see RowSqlProvider#updateNumberAddByQuery(Map)
+ */
+ @UpdateProvider(type = RowSqlProvider.class, method = "updateNumberAddByQuery")
+ int updateNumberAddByQuery(@Param(FlexConsts.TABLE_NAME) String tableName, @Param(FlexConsts.FIELD_NAME) String fieldName
+ , @Param(FlexConsts.VALUE) Number value, @Param(FlexConsts.QUERY) QueryWrapper queryWrapper);
+
+
///////select /////
/**
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowMapperInvoker.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowMapperInvoker.java
index 982fb710..472d9a7d 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowMapperInvoker.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowMapperInvoker.java
@@ -185,4 +185,7 @@ public class RowMapperInvoker {
}
+ public int updateNumberAddByQuery(String tableName, String fieldName, Number value, QueryWrapper queryWrapper) {
+ return execute(mapper -> mapper.updateNumberAddByQuery(tableName, fieldName, value, queryWrapper));
+ }
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowUtil.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowUtil.java
index ec9a3bfb..0733acae 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowUtil.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/row/RowUtil.java
@@ -133,6 +133,9 @@ public class RowUtil {
public static void printPretty(Row row) {
+ if (row == null) {
+ return;
+ }
printPretty(Collections.singletonList(row));
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java
index 52ddf99d..65617acf 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfo.java
@@ -266,6 +266,10 @@ public class TableInfo {
return columnInfoList;
}
+ public String getColumnByProperty(String property) {
+ return propertyColumnMapping.get(property);
+ }
+
void setColumnInfoList(List columnInfoList) {
this.columnInfoList = columnInfoList;
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/ClassUtil.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/ClassUtil.java
index 33c9619a..1c8ead73 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/ClassUtil.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/ClassUtil.java
@@ -67,7 +67,7 @@ public class ClassUtil {
}
- public static Class> wrap(Class> clazz) {
+ public static Class> getWrapType(Class> clazz) {
if (clazz == null || !clazz.isPrimitive()) {
return clazz;
}
@@ -181,17 +181,23 @@ public class ClassUtil {
public static List getAllFields(Class> cl) {
List fields = new ArrayList<>();
- doGetFields(cl, fields, null);
+ doGetFields(cl, fields, null, false);
return fields;
}
public static List getAllFields(Class> cl, Predicate predicate) {
List fields = new ArrayList<>();
- doGetFields(cl, fields, predicate);
+ doGetFields(cl, fields, predicate, false);
return fields;
}
- private static void doGetFields(Class> cl, List fields, Predicate predicate) {
+ public static Field getFirstField(Class> cl, Predicate predicate) {
+ List fields = new ArrayList<>();
+ doGetFields(cl, fields, predicate, true);
+ return fields.isEmpty() ? null : fields.get(0);
+ }
+
+ private static void doGetFields(Class> cl, List fields, Predicate predicate, boolean firstOnly) {
if (cl == null || cl == Object.class) {
return;
}
@@ -200,26 +206,39 @@ public class ClassUtil {
for (Field declaredField : declaredFields) {
if (predicate == null || predicate.test(declaredField)) {
fields.add(declaredField);
+ if (firstOnly) {
+ break;
+ }
}
}
- doGetFields(cl.getSuperclass(), fields, predicate);
+ if (firstOnly && !fields.isEmpty()) {
+ return;
+ }
+
+ doGetFields(cl.getSuperclass(), fields, predicate, firstOnly);
}
public static List getAllMethods(Class> cl) {
List methods = new ArrayList<>();
- doGetMethods(cl, methods, null);
+ doGetMethods(cl, methods, null, false);
return methods;
}
public static List getAllMethods(Class> cl, Predicate predicate) {
List methods = new ArrayList<>();
- doGetMethods(cl, methods, predicate);
+ doGetMethods(cl, methods, predicate, false);
return methods;
}
+ public static Method getFirstMethod(Class> cl, Predicate predicate) {
+ List methods = new ArrayList<>();
+ doGetMethods(cl, methods, predicate, true);
+ return methods.isEmpty() ? null : methods.get(0);
+ }
- private static void doGetMethods(Class> cl, List methods, Predicate predicate) {
+
+ private static void doGetMethods(Class> cl, List methods, Predicate predicate, boolean firstOnly) {
if (cl == null || cl == Object.class) {
return;
}
@@ -228,10 +247,17 @@ public class ClassUtil {
for (Method method : declaredMethods) {
if (predicate == null || predicate.test(method)) {
methods.add(method);
+ if (firstOnly) {
+ break;
+ }
}
}
- doGetMethods(cl.getSuperclass(), methods, predicate);
+ if (firstOnly && !methods.isEmpty()) {
+ return;
+ }
+
+ doGetMethods(cl.getSuperclass(), methods, predicate, firstOnly);
}
private static Class getJdkProxySuperClass(Class clazz) {
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/ConvertUtil.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/ConvertUtil.java
index 61147aeb..1e0ecfa1 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/ConvertUtil.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/ConvertUtil.java
@@ -94,7 +94,7 @@ public class ConvertUtil {
} else if (targetClass.isEnum()) {
EnumWrapper enumWrapper = EnumWrapper.of(targetClass);
if (enumWrapper.hasEnumValueAnnotation()) {
- return enumWrapper.toEnum(value);
+ return enumWrapper.getEnum(value);
} else if (value instanceof String) {
return Enum.valueOf(targetClass, value.toString());
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/EnumWrapper.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/EnumWrapper.java
index 75522b7e..58b0931e 100644
--- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/EnumWrapper.java
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/EnumWrapper.java
@@ -22,7 +22,6 @@ import org.apache.ibatis.util.MapUtil;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -30,13 +29,13 @@ public class EnumWrapper> {
private static final Map cache = new ConcurrentHashMap<>();
- private Class> enumClass;
+ private boolean hasEnumValueAnnotation = false;
- private Class> enumPropertyType;
+ private Class> enumClass;
private E[] enums;
private Field property;
- private Method getter;
- private boolean hasEnumValueAnnotation = false;
+ private Class> propertyType;
+ private Method getterMethod;
public static > EnumWrapper of(Class> enumClass) {
return MapUtil.computeIfAbsent(cache, enumClass, EnumWrapper::new);
@@ -44,32 +43,31 @@ public class EnumWrapper> {
public EnumWrapper(Class enumClass) {
this.enumClass = enumClass;
+ this.enums = enumClass.getEnumConstants();
- List allFields = ClassUtil.getAllFields(enumClass, field -> field.getAnnotation(EnumValue.class) != null);
- if (!allFields.isEmpty()) {
+ Field enumValueField = ClassUtil.getFirstField(enumClass, field -> field.getAnnotation(EnumValue.class) != null);
+ if (enumValueField != null) {
hasEnumValueAnnotation = true;
}
if (hasEnumValueAnnotation) {
- Field field = allFields.get(0);
+ String getterMethodName = "get" + StringUtil.firstCharToUpperCase(enumValueField.getName());
- String fieldGetterName = "get" + StringUtil.firstCharToUpperCase(field.getName());
- List allMethods = ClassUtil.getAllMethods(enumClass, method -> {
+ Method getter = ClassUtil.getFirstMethod(enumClass, method -> {
String methodName = method.getName();
- return methodName.equals(fieldGetterName);
+ return methodName.equals(getterMethodName) && Modifier.isPublic(method.getModifiers());
});
- enumPropertyType = ClassUtil.wrap(field.getType());
- enums = enumClass.getEnumConstants();
+ propertyType = ClassUtil.getWrapType(enumValueField.getType());
- if (allMethods.isEmpty()) {
- if (Modifier.isPublic(field.getModifiers())) {
- property = field;
+ if (getter == null) {
+ if (Modifier.isPublic(enumValueField.getModifiers())) {
+ property = enumValueField;
} else {
- throw new IllegalStateException("Can not find \"" + fieldGetterName + "()\" method in enum: " + enumClass.getName());
+ throw new IllegalStateException("Can not find method \"" + getterMethodName + "()\" in enum: " + enumClass.getName());
}
} else {
- getter = allMethods.get(0);
+ this.getterMethod = getter;
}
}
}
@@ -77,16 +75,14 @@ public class EnumWrapper> {
public Object getEnumValue(E object) {
try {
- return getter != null
- ? getter.invoke(object)
- : property.get(object);
+ return getterMethod != null ? getterMethod.invoke(object) : property.get(object);
} catch (Exception e) {
throw FlexExceptions.wrap(e);
}
}
- public E toEnum(Object value) {
+ public E getEnum(Object value) {
for (E e : enums) {
if (value.equals(getEnumValue(e))) {
return e;
@@ -95,12 +91,12 @@ public class EnumWrapper> {
return null;
}
- public Class> getEnumClass() {
- return enumClass;
+ public boolean hasEnumValueAnnotation() {
+ return hasEnumValueAnnotation;
}
- public Class> getEnumPropertyType() {
- return enumPropertyType;
+ public Class> getEnumClass() {
+ return enumClass;
}
public E[] getEnums() {
@@ -111,11 +107,11 @@ public class EnumWrapper> {
return property;
}
- public Method getGetter() {
- return getter;
+ public Class> getPropertyType() {
+ return propertyType;
}
- public boolean hasEnumValueAnnotation() {
- return hasEnumValueAnnotation;
+ public Method getGetterMethod() {
+ return getterMethod;
}
}
diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/FieldWrapper.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/FieldWrapper.java
new file mode 100644
index 00000000..59dfc80f
--- /dev/null
+++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/util/FieldWrapper.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.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.mybatisflex.core.util;
+
+import java.lang.reflect.*;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class FieldWrapper {
+
+ public static Map, Map> cache = new ConcurrentHashMap<>();
+
+ private Class> fieldType;
+ private Class> mappingType;
+ private Method setterMethod;
+
+ public static FieldWrapper of(Class> clazz, String fieldName) {
+ Map wrapperMap = cache.get(clazz);
+ if (wrapperMap == null) {
+ synchronized (clazz) {
+ if (wrapperMap == null) {
+ wrapperMap = new ConcurrentHashMap<>();
+ cache.put(clazz, wrapperMap);
+ }
+ }
+ }
+
+ FieldWrapper fieldWrapper = wrapperMap.get(fieldName);
+ if (fieldWrapper == null) {
+ synchronized (clazz) {
+ fieldWrapper = wrapperMap.get(fieldName);
+ if (fieldWrapper == null) {
+ Field findField = ClassUtil.getFirstField(clazz, field -> field.getName().equals(fieldName));
+ if (findField == null) {
+ throw new IllegalStateException("Can not find field \"" + fieldName + "\" in class: " + clazz);
+ }
+
+ Method setter = ClassUtil.getFirstMethod(clazz, method ->
+ method.getParameterCount() == 1
+ && Modifier.isPublic(method.getModifiers())
+ && method.getName().equals("set" + StringUtil.firstCharToUpperCase(fieldName)));
+
+ if (setter == null) {
+ throw new IllegalStateException("Can not find method \"set" + StringUtil.firstCharToUpperCase(fieldName) + "\" in class: " + clazz);
+ }
+
+ fieldWrapper = new FieldWrapper();
+ fieldWrapper.fieldType = findField.getType();
+ fieldWrapper.mappingType = parseMappingType(findField);
+ fieldWrapper.setterMethod = setter;
+
+ wrapperMap.put(fieldName, fieldWrapper);
+ }
+ }
+ }
+
+ return fieldWrapper;
+ }
+
+ private static Class> parseMappingType(Field field) {
+ Class> fieldType = field.getType();
+ if (Collection.class.isAssignableFrom(fieldType)) {
+ Type genericType = field.getGenericType();
+ if (genericType instanceof ParameterizedType) {
+ Type actualTypeArgument = ((ParameterizedType) genericType).getActualTypeArguments()[0];
+ return (Class>) actualTypeArgument;
+ }
+ }
+
+ if (fieldType.isArray()) {
+ return field.getType().getComponentType();
+ }
+
+ return fieldType;
+ }
+
+
+ public void set(Object value, Object to) {
+ try {
+ setterMethod.invoke(to, value);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Class> getFieldType() {
+ return fieldType;
+ }
+
+ public Class> getMappingType() {
+ return mappingType;
+ }
+}
diff --git a/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/query/ArithmeticQueryColumnTest.java b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/query/ArithmeticQueryColumnTest.java
new file mode 100644
index 00000000..57e31e5e
--- /dev/null
+++ b/mybatis-flex-core/src/test/java/com/mybatisflex/coretest/query/ArithmeticQueryColumnTest.java
@@ -0,0 +1,148 @@
+/**
+ * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.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.mybatisflex.coretest.query;
+
+import com.mybatisflex.core.dialect.IDialect;
+import com.mybatisflex.core.dialect.impl.CommonsDialectImpl;
+import com.mybatisflex.core.query.QueryWrapper;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static com.mybatisflex.core.query.QueryMethods.sum;
+import static com.mybatisflex.coretest.table.AccountTableDef.ACCOUNT;
+
+public class ArithmeticQueryColumnTest {
+
+ private static String toSql(QueryWrapper queryWrapper){
+ IDialect dialect = new CommonsDialectImpl();
+ return dialect.forSelectByQuery(queryWrapper);
+ }
+
+
+ @Test
+ public void testAdd() {
+ QueryWrapper query = new QueryWrapper()
+ .select(ACCOUNT.ID.add(100).as("x100"))
+ .from(ACCOUNT);
+
+ String sql = toSql(query);
+ System.out.println(sql);
+
+ Assert.assertEquals(sql,"SELECT (`id` + 100) AS `x100` FROM `tb_account`");
+ }
+
+ @Test
+ public void testAdd1() {
+ QueryWrapper query = new QueryWrapper()
+ .select(ACCOUNT.ID.add(100).add(200).add(300).as("x100"))
+ .from(ACCOUNT);
+
+ String sql = toSql(query);
+ System.out.println(sql);
+
+ Assert.assertEquals(sql,"SELECT (`id` + 100 + 200 + 300) AS `x100` FROM `tb_account`");
+ }
+
+ @Test
+ public void testAdd2() {
+ QueryWrapper query = new QueryWrapper()
+ .select(ACCOUNT.ID.add(ACCOUNT.ID).as("x100"))
+ .from(ACCOUNT);
+
+ String sql = toSql(query);
+ System.out.println(sql);
+
+ Assert.assertEquals(sql,"SELECT (`id` + `id`) AS `x100` FROM `tb_account`");
+ }
+
+ @Test
+ public void testAdd3() {
+ QueryWrapper query = new QueryWrapper()
+ .select(ACCOUNT.ID.add(ACCOUNT.ID.add(100)).as("x100"))
+ .from(ACCOUNT);
+
+ String sql = toSql(query);
+ System.out.println(sql);
+
+ Assert.assertEquals(sql,"SELECT (`id` + (`id` + 100)) AS `x100` FROM `tb_account`");
+ }
+
+ @Test
+ public void testAdd4() {
+ QueryWrapper query = new QueryWrapper()
+ .select(ACCOUNT.ID.add(ACCOUNT.ID.add(100)).multiply(100).as("x100"))
+ .from(ACCOUNT);
+
+ String sql = toSql(query);
+ System.out.println(sql);
+
+ Assert.assertEquals(sql,"SELECT (`id` + (`id` + 100) * 100) AS `x100` FROM `tb_account`");
+ }
+
+ @Test
+ public void testAdd5() {
+ QueryWrapper query = new QueryWrapper()
+ .select(sum(ACCOUNT.ID.multiply(ACCOUNT.AGE)).as("total_x"))
+ .from(ACCOUNT);
+
+ String sql = toSql(query);
+ System.out.println(sql);
+
+ Assert.assertEquals(sql,"SELECT SUM(`id` * `age`) AS `total_x` FROM `tb_account`");
+ }
+
+ @Test
+ public void testSubtract() {
+ QueryWrapper query = new QueryWrapper()
+ .select(ACCOUNT.ID.subtract(100).as("x100"))
+ .from(ACCOUNT);
+
+ String sql = toSql(query);
+ System.out.println(sql);
+
+ Assert.assertEquals(sql,"SELECT (`id` - 100) AS `x100` FROM `tb_account`");
+ }
+
+
+ @Test
+ public void testMultiply() {
+ QueryWrapper query = new QueryWrapper()
+ .select(ACCOUNT.ID.multiply(100).as("x100"))
+ .from(ACCOUNT);
+
+ String sql = toSql(query);
+ System.out.println(sql);
+
+ Assert.assertEquals(sql,"SELECT (`id` * 100) AS `x100` FROM `tb_account`");
+ }
+
+
+ @Test
+ public void testDivide() {
+ QueryWrapper query = new QueryWrapper()
+ .select(ACCOUNT.ID.divide(100).as("x100"))
+ .from(ACCOUNT);
+
+ String sql = toSql(query);
+ System.out.println(sql);
+
+ Assert.assertEquals(sql,"SELECT (`id` / 100) AS `x100` FROM `tb_account`");
+ }
+
+
+
+
+}
diff --git a/mybatis-flex-processor/pom.xml b/mybatis-flex-processor/pom.xml
index 2687b22c..803ddf6e 100644
--- a/mybatis-flex-processor/pom.xml
+++ b/mybatis-flex-processor/pom.xml
@@ -5,7 +5,7 @@
parent
com.mybatis-flex
- 1.3.0
+ 1.3.2
4.0.0
@@ -20,7 +20,7 @@
com.mybatis-flex
mybatis-flex-annotation
- 1.3.0
+ 1.3.2
diff --git a/mybatis-flex-solon-plugin/pom.xml b/mybatis-flex-solon-plugin/pom.xml
index 9b8dfa14..bc0d237b 100644
--- a/mybatis-flex-solon-plugin/pom.xml
+++ b/mybatis-flex-solon-plugin/pom.xml
@@ -5,7 +5,7 @@
parent
com.mybatis-flex
- 1.3.0
+ 1.3.2
4.0.0
@@ -15,7 +15,7 @@
com.mybatis-flex
mybatis-flex-core
- 1.3.0
+ 1.3.2
diff --git a/mybatis-flex-spring-boot-starter/pom.xml b/mybatis-flex-spring-boot-starter/pom.xml
index f0e6b2e8..cb4f7680 100644
--- a/mybatis-flex-spring-boot-starter/pom.xml
+++ b/mybatis-flex-spring-boot-starter/pom.xml
@@ -5,7 +5,7 @@
parent
com.mybatis-flex
- 1.3.0
+ 1.3.2
4.0.0
@@ -21,7 +21,7 @@
com.mybatis-flex
mybatis-flex-spring
- 1.3.0
+ 1.3.2
diff --git a/mybatis-flex-spring/pom.xml b/mybatis-flex-spring/pom.xml
index 4e7a1eef..f6ad65fa 100644
--- a/mybatis-flex-spring/pom.xml
+++ b/mybatis-flex-spring/pom.xml
@@ -5,7 +5,7 @@
parent
com.mybatis-flex
- 1.3.0
+ 1.3.2
4.0.0
@@ -20,7 +20,7 @@
com.mybatis-flex
mybatis-flex-core
- 1.3.0
+ 1.3.2
diff --git a/mybatis-flex-test/mybatis-flex-native-test/pom.xml b/mybatis-flex-test/mybatis-flex-native-test/pom.xml
index 16d7ea84..d195fb13 100644
--- a/mybatis-flex-test/mybatis-flex-native-test/pom.xml
+++ b/mybatis-flex-test/mybatis-flex-native-test/pom.xml
@@ -5,7 +5,7 @@
mybatis-flex-test
com.mybatis-flex
- 1.3.0
+ 1.3.2
4.0.0
@@ -20,7 +20,7 @@
com.mybatis-flex
mybatis-flex-core
- 1.3.0
+ 1.3.2
diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/DbTestStarter.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/DbTestStarter.java
index b38459bf..02366b9e 100644
--- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/DbTestStarter.java
+++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/DbTestStarter.java
@@ -16,10 +16,7 @@
package com.mybatisflex.test;
import com.mybatisflex.core.MybatisFlexBootstrap;
-import com.mybatisflex.core.row.BatchArgsSetter;
-import com.mybatisflex.core.row.Db;
-import com.mybatisflex.core.row.Row;
-import com.mybatisflex.core.row.RowKey;
+import com.mybatisflex.core.row.*;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
@@ -33,7 +30,7 @@ public class DbTestStarter {
DataSource dataSource = new EmbeddedDatabaseBuilder()
.setType(EmbeddedDatabaseType.H2)
.addScript("schema.sql")
- .addScript("data.sql")
+// .addScript("data.sql")
.build();
MybatisFlexBootstrap.getInstance()
@@ -41,15 +38,18 @@ public class DbTestStarter {
.start();
Row row1 = Db.selectOneById("tb_account", "id", 1);
- System.out.println(row1);
+ RowUtil.printPretty(row1);
//查询全部
List rows = Db.selectAll("tb_account");
- System.out.println(rows);
+ RowUtil.printPretty(rows);
//插入 1 条数据
- Row row = Row.ofKey(RowKey.ID_AUTO);
+
+ Row row = Row.ofKey(RowKey.AUTO);
+// Row row = new Row();
+// row.set("id", 3);
row.set("user_name", "michael yang");
row.set("age", 18);
row.set("birthday", new Date());
@@ -80,6 +80,26 @@ public class DbTestStarter {
//再次查询全部数据
rows = Db.selectAll("tb_account");
- System.out.println(rows);
+ RowUtil.printPretty(rows);
+
+// for (Row row2 : rows) {
+//// for (String s : row2.keySet()) {
+//// if (!s.equalsIgnoreCase("id")) {
+//// row2.set(s, row2.get(s));
+//// }
+//// }
+// rows.remove("id");
+// }
+
+// rows.forEach(row2 -> row2.setPrimaryKeys(RowKey.AUTO));
+ rows.forEach(r -> {
+ r.prepareAttrsByKeySet();
+ r.setPrimaryKeys(RowKey.AUTO);
+ });
+ Db.insertBatch("tb_account", rows, 100);
+
+ //再次查询全部数据
+ rows = Db.selectAll("tb_account");
+ RowUtil.printPretty(rows);
}
}
diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java
index 317c04e5..adae7e68 100644
--- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java
+++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/EntityTestStarter.java
@@ -71,15 +71,22 @@ public class EntityTestStarter {
RowUtil.printPretty(rowList);
-// List accounts1 = accountMapper.selectListByQuery(QueryWrapper.create()
-// , accountFieldQueryBuilder -> accountFieldQueryBuilder
-// .field(Account::getArticles)
-// .type(Article.class)
-// .queryWrapper(entity ->
-// select().from(ARTICLE).where(ARTICLE.ACCOUNT_ID.eq(entity.getId()))
-// )
-// );
-// System.out.println(accounts1);
+ accountMapper.updateNumberAddByQuery("age", 100, QueryWrapper.create().where(ACCOUNT.ID.eq(1)));
+ accountMapper.updateNumberAddByQuery(Account::getAge, -50, QueryWrapper.create().where(ACCOUNT.ID.eq(1)));
+
+
+ Db.updateNumberAddByQuery("tb_account", "age", 30, QueryWrapper.create().where(ACCOUNT.ID.eq(1)));
+ Db.updateNumberAddByQuery("tb_account", "age", -20, QueryWrapper.create().where(ACCOUNT.ID.eq(1)));
+
+
+ List accounts1 = accountMapper.selectListByQuery(QueryWrapper.create()
+ , accountFieldQueryBuilder -> accountFieldQueryBuilder
+ .field(Account::getArticles)
+ .queryWrapper(entity ->
+ select().from(ARTICLE).where(ARTICLE.ACCOUNT_ID.eq(entity.getId()))
+ )
+ );
+ System.out.println(accounts1);
// MyAccountMapper myAccountMapper = bootstrap.getMapper(MyAccountMapper.class);
diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/RowTestStarter.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/RowTestStarter.java
index c7ec5f77..f748af46 100644
--- a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/RowTestStarter.java
+++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/RowTestStarter.java
@@ -75,7 +75,7 @@ public class RowTestStarter {
List rowList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
- Row row = Row.ofKey(RowKey.ID_AUTO);
+ Row row = Row.ofKey(RowKey.AUTO);
row.set(ACCOUNT.USER_NAME,"zhang" + i);
row.set(ACCOUNT.AGE,18);
// row.set(ACCOUNT.BIRTHDAY,new Date());
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml b/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml
index d4ea3a9a..2616acfc 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml
@@ -5,7 +5,7 @@
mybatis-flex-test
com.mybatis-flex
- 1.3.0
+ 1.3.2
4.0.0
@@ -21,7 +21,7 @@
com.mybatis-flex
mybatis-flex-spring-boot-starter
- 1.3.0
+ 1.3.2
diff --git a/mybatis-flex-test/mybatis-flex-spring-test/pom.xml b/mybatis-flex-test/mybatis-flex-spring-test/pom.xml
index 325f5b48..a26f9fe1 100644
--- a/mybatis-flex-test/mybatis-flex-spring-test/pom.xml
+++ b/mybatis-flex-test/mybatis-flex-spring-test/pom.xml
@@ -5,7 +5,7 @@
mybatis-flex-test
com.mybatis-flex
- 1.3.0
+ 1.3.2
4.0.0
@@ -20,13 +20,13 @@
com.mybatis-flex
mybatis-flex-core
- 1.3.0
+ 1.3.2
com.mybatis-flex
mybatis-flex-spring
- 1.3.0
+ 1.3.2
diff --git a/mybatis-flex-test/pom.xml b/mybatis-flex-test/pom.xml
index 378b7960..a2090d8a 100644
--- a/mybatis-flex-test/pom.xml
+++ b/mybatis-flex-test/pom.xml
@@ -5,7 +5,7 @@
parent
com.mybatis-flex
- 1.3.0
+ 1.3.2
4.0.0
@@ -59,7 +59,7 @@
com.mybatis-flex
mybatis-flex-processor
- 1.3.0
+ 1.3.2
diff --git a/pom.xml b/pom.xml
index 78d6417d..992467f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
com.mybatis-flex
parent
pom
- 1.3.0
+ 1.3.2
mybatis-flex
https://mybatis-flex.com