1.修复MybatisKeyGeneratorUtil类的空指针异常

2.修复MapperInvocationHandler的数据类型强转异常
This commit is contained in:
norkts 2023-08-13 01:53:24 +08:00
parent 09d649d296
commit 062723a69c
2 changed files with 13 additions and 2 deletions

View File

@ -56,6 +56,12 @@ public class MybatisKeyGeneratorUtil {
public static KeyGenerator createIdKeyGenerator(TableInfo tableInfo, MappedStatement ms, IdInfo idInfo) { public static KeyGenerator createIdKeyGenerator(TableInfo tableInfo, MappedStatement ms, IdInfo idInfo) {
FlexGlobalConfig flexGlobalConfig = FlexGlobalConfig.getConfig(ms.getConfiguration());
if(flexGlobalConfig == null){
return NoKeyGenerator.INSTANCE;
}
FlexGlobalConfig.KeyConfig globalKeyConfig = FlexGlobalConfig.getConfig(ms.getConfiguration()).getKeyConfig(); FlexGlobalConfig.KeyConfig globalKeyConfig = FlexGlobalConfig.getConfig(ms.getConfiguration()).getKeyConfig();
KeyType keyType = getKeyType(idInfo, globalKeyConfig); KeyType keyType = getKeyType(idInfo, globalKeyConfig);

View File

@ -41,7 +41,12 @@ public class MapperInvocationHandler implements InvocationHandler {
public MapperInvocationHandler(Object mapper, DataSource dataSource) { public MapperInvocationHandler(Object mapper, DataSource dataSource) {
this.mapper = mapper; this.mapper = mapper;
this.dataSource = (FlexDataSource) dataSource; if(dataSource instanceof FlexDataSource){
this.dataSource = (FlexDataSource) dataSource;
}else{
this.dataSource = null;
}
} }
@ -65,7 +70,7 @@ public class MapperInvocationHandler implements InvocationHandler {
//优先获取用户自己配置的 dbType //优先获取用户自己配置的 dbType
DbType dbType = DialectFactory.getHintDbType(); DbType dbType = DialectFactory.getHintDbType();
if (dbType == null) { if (dbType == null) {
if (dataSourceKey != null) { if (dataSourceKey != null && dataSource != null) {
dbType = dataSource.getDbType(dataSourceKey); dbType = dataSource.getDbType(dataSourceKey);
} }
if (dbType == null) { if (dbType == null) {