diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/activerecord/query/QueryModel.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/activerecord/query/QueryModel.java index ac4372b2..ad7484aa 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/activerecord/query/QueryModel.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/activerecord/query/QueryModel.java @@ -16,7 +16,6 @@ package com.mybatisflex.core.activerecord.query; -import com.mybatisflex.annotation.Column; import com.mybatisflex.core.constant.SqlConsts; import com.mybatisflex.core.query.*; import com.mybatisflex.core.table.TableDef; @@ -39,7 +38,6 @@ import com.mybatisflex.core.util.LambdaUtil; @SuppressWarnings({"unused", "unchecked"}) public abstract class QueryModel> { - @Column(ignore = true) private QueryWrapper queryWrapper; protected QueryWrapper queryWrapper() { diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/MapperQueryChain.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/MapperQueryChain.java index 31886606..134ac2e7 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/MapperQueryChain.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/query/MapperQueryChain.java @@ -74,6 +74,7 @@ public interface MapperQueryChain extends ChainQuery { /** * {@inheritDoc} */ + @Override default T one() { return baseMapper().selectOneByQuery(toQueryWrapper()); } @@ -81,6 +82,7 @@ public interface MapperQueryChain extends ChainQuery { /** * {@inheritDoc} */ + @Override default R oneAs(Class asType) { return baseMapper().selectOneByQueryAs(toQueryWrapper(), asType); } diff --git a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java index 30c8741e..4f8c6121 100644 --- a/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java +++ b/mybatis-flex-core/src/main/java/com/mybatisflex/core/table/TableInfoFactory.java @@ -19,6 +19,10 @@ import com.mybatisflex.annotation.*; import com.mybatisflex.core.BaseMapper; import com.mybatisflex.core.FlexGlobalConfig; import com.mybatisflex.core.exception.FlexExceptions; +import com.mybatisflex.core.query.QueryChain; +import com.mybatisflex.core.query.QueryColumn; +import com.mybatisflex.core.query.QueryCondition; +import com.mybatisflex.core.query.QueryWrapper; import com.mybatisflex.core.util.ClassUtil; import com.mybatisflex.core.util.CollectionUtil; import com.mybatisflex.core.util.Reflectors; @@ -61,6 +65,10 @@ public class TableInfoFactory { char.class, String.class, Character.class ); + static final Set> ignoreColumnTypes = CollectionUtil.newHashSet( + QueryWrapper.class, QueryColumn.class, QueryCondition.class, QueryChain.class + ); + private static final Map, TableInfo> mapperTableInfoMap = new ConcurrentHashMap<>(); private static final Map, TableInfo> entityTableMap = new ConcurrentHashMap<>(); @@ -206,6 +214,9 @@ public class TableInfoFactory { // } Class fieldType = reflector.getGetterType(field.getName()); + if (ignoreColumnTypes.contains(fieldType)) { + continue; + } //满足以下 3 种情况,不支持该类型 if ((column == null || column.typeHandler() == UnknownTypeHandler.class) // 未配置 typeHandler diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/controller/AccountController.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/controller/AccountController.java index 20ed3ae2..43288bce 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/controller/AccountController.java +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/java/com/mybatisflex/test/controller/AccountController.java @@ -69,6 +69,10 @@ public class AccountController { DataSourceKey.use("ds2"); accountMapper.insert(account); +// if (true) { +// throw new RuntimeException("ex"); +// } + return "add ok!"; } diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml index a3e0f77e..9945e8b6 100644 --- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml +++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/main/resources/application.yml @@ -1,13 +1,13 @@ # DataSource Config -spring: - # h2: - # console: - # enabled: true - datasource: -# driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/flex_test - username: root - password: 123456 +#spring: +# # h2: +# # console: +# # enabled: true +# datasource: +## driver-class-name: com.mysql.cj.jdbc.Driver +# url: jdbc:mysql://localhost:3306/flex_test +# username: root +# password: 123456 # driver-class-name: # datasource: # driver-class-name: org.h2.Driver @@ -36,13 +36,13 @@ spring: # url: jdbc:mysql://localhost:3306/flex_test # username: root # password: 12345678 -#mybatis-flex: -# datasource: -# ds1: -# url: jdbc:mysql://127.0.0.1:3306/flex_test -# username: root -# password: 123456 -# ds2: -# url: jdbc:mysql://127.0.0.1:3306/flex_test -# username: root -# password: 123456 +mybatis-flex: + datasource: + ds1: + url: jdbc:mysql://127.0.0.1:3306/flex_test + username: root + password: 123456 + ds2: + url: jdbc:mysql://127.0.0.1:3306/flex_test + username: root + password: 123456