Browse Source

存储过程的 params 是 List。MyBatis 对集合/数组调用 hasSetter 会抛 UnsupportedOperationException,

clodop
han\hanst 1 month ago
parent
commit
4a63c0ba7f
  1. 6
      src/main/java/com/gaotao/config/MybatisLoginUserInterceptor.java

6
src/main/java/com/gaotao/config/MybatisLoginUserInterceptor.java

@ -20,6 +20,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.sql.Connection;
import java.util.Collection;
import java.util.Map;
import java.util.Properties;
@ -89,6 +90,11 @@ public class MybatisLoginUserInterceptor implements Interceptor {
}
return;
}
// 存储过程的 params 是 List。MyBatis 对集合/数组调用 hasSetter 会抛 UnsupportedOperationException,
// 请求在 exec 之前就失败。登录名也不能塞进过程实参,否则会多出一个参数。
if (bean instanceof Collection || bean.getClass().isArray()) {
return;
}
MetaObject metaObject = SystemMetaObject.forObject(bean);
if (metaObject.hasSetter(LOGIN_USER_PARAM) && metaObject.getValue(LOGIN_USER_PARAM) == null) {
metaObject.setValue(LOGIN_USER_PARAM, loginUserName);

Loading…
Cancel
Save