4747import indi .mybatis .flying .exception .AutoMapperExceptionEnum ;
4848import indi .mybatis .flying .models .Conditionable ;
4949import indi .mybatis .flying .models .FlyingModel ;
50+ import indi .mybatis .flying .models .ParameterObjectContextHolder ;
5051import indi .mybatis .flying .utils .CookOriginalSql ;
5152import indi .mybatis .flying .utils .ReflectHelper ;
5253
@@ -88,6 +89,8 @@ public Object intercept(Invocation invocation) throws Throwable {
8889 String originalSql = (String ) metaStatementHandler .getValue (DELEGATE_BOUNDSQL_SQL );
8990 Configuration configuration = (Configuration ) metaStatementHandler .getValue (DELEGATE_CONFIGURATION );
9091 Object parameterObject = metaStatementHandler .getValue (DELEGATE_BOUNDSQL_PARAMETEROBJECT );
92+ // save parameterObject with ThreadLocal
93+ ParameterObjectContextHolder .set (parameterObject );
9194 FlyingModel flyingModel = CookOriginalSql .fetchFlyingFeature (originalSql );
9295 MappedStatement mappedStatement = (MappedStatement ) metaStatementHandler .getValue (DELEGATE_MAPPEDSTATEMENT );
9396 if (flyingModel .isHasFlyingFeature ()) {
@@ -229,7 +232,9 @@ private SqlSource buildSqlSource(Configuration configuration, String originalSql
229232
230233 @ SuppressWarnings ("unchecked" )
231234 private void setParameters (PreparedStatement ps , MappedStatement mappedStatement , BoundSql boundSql ,
232- Object parameterObject ) throws SQLException {
235+ Object parameterObject2 ) throws SQLException {
236+ // get thread-safe parameterObject from ThreadLocal
237+ Object parameterObject = ParameterObjectContextHolder .get ();
233238 ErrorContext .instance ().activity (SETTING_PARAMETERS ).object (mappedStatement .getParameterMap ().getId ());
234239 List <ParameterMapping > parameterMappings = boundSql .getParameterMappings ();
235240 if (parameterMappings != null ) {
@@ -301,4 +306,4 @@ private String generatePageSql(String sql, Conditionable condition) {
301306 return sql ;
302307 }
303308 }
304- }
309+ }
0 commit comments