|
@@ -43,6 +43,7 @@ import org.apache.ibatis.session.SqlSessionFactory;
|
|
|
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
|
|
|
import org.apache.ibatis.transaction.TransactionFactory;
|
|
|
import org.apache.ibatis.type.TypeHandler;
|
|
|
+import org.apache.ibatis.type.TypeHandlerRegistry;
|
|
|
import org.mybatis.spring.SqlSessionFactoryBean;
|
|
|
import org.mybatis.spring.transaction.SpringManagedTransactionFactory;
|
|
|
import org.springframework.beans.factory.FactoryBean;
|
|
@@ -107,6 +108,9 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
|
|
|
|
|
|
private String typeAliasesPackage;
|
|
|
|
|
|
+ // TODO 自定义枚举包
|
|
|
+ private String typeEnumsPackage;
|
|
|
+
|
|
|
private Class<?> typeAliasesSuperType;
|
|
|
|
|
|
//issue #19. No default provider.
|
|
@@ -204,6 +208,10 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
|
|
|
this.typeAliasesPackage = typeAliasesPackage;
|
|
|
}
|
|
|
|
|
|
+ public void setTypeEnumsPackage(String typeEnumsPackage) {
|
|
|
+ this.typeEnumsPackage = typeEnumsPackage;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Super class which domain objects have to extend to have a type alias created.
|
|
|
* No effect if there is no package to scan configured.
|
|
@@ -445,6 +453,27 @@ public class MybatisSqlSessionFactoryBean implements FactoryBean<SqlSessionFacto
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // TODO 自定义枚举包扫描处理
|
|
|
+ if (hasLength(this.typeEnumsPackage)) {
|
|
|
+ // 取得类型转换注册器
|
|
|
+ String[] typeEnumsPackageArray;
|
|
|
+ if (typeEnumsPackage.contains("*") && !typeEnumsPackage.contains(",")
|
|
|
+ && !typeEnumsPackage.contains(";")) {
|
|
|
+ typeEnumsPackageArray = PackageHelper.convertTypeAliasesPackage(typeEnumsPackage);
|
|
|
+ } else {
|
|
|
+ typeEnumsPackageArray = tokenizeToStringArray(this.typeEnumsPackage,
|
|
|
+ ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
|
|
|
+ }
|
|
|
+ if (typeEnumsPackageArray == null) {
|
|
|
+ throw new MybatisPlusException("not find typeEnumsPackage:" + typeEnumsPackage);
|
|
|
+ }
|
|
|
+ TypeHandlerRegistry typeHandlerRegistry = this.configuration.getTypeHandlerRegistry();
|
|
|
+ for (String packageToScan : typeEnumsPackageArray) {
|
|
|
+ // 注册 TODO
|
|
|
+// typeHandlerRegistry.register(className, "com.baomidou.mybatisplus.enums.IEnumTypeHandler");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (!isEmpty(this.typeAliases)) {
|
|
|
for (Class<?> typeAlias : this.typeAliases) {
|
|
|
configuration.getTypeAliasRegistry().registerAlias(typeAlias);
|