MyBatis interceptor: assigning values to parameter object properties
1 package com.development; 2 3 import java.lang.reflect.InvocationTargetException; 4 import java.util.Date; 5 import java.util.Map; 6 import java.util.Properties; 7 8 import org.apache.commons.beanutils.BeanUtils; 9 import org.apache.ibatis.executor.Executor; 10 import org.apache.ibatis.mapping.MappedStatement; 11 import org.apache.ibatis.mapping.SqlCommandType; 12 import org.apache.ibatis.plugin.Interceptor; 13 import org.apache.ibatis.plugin.Intercepts 14 import org.apache.ibatis.plugin.Invocation; 15 import org.apache.ibatis.plugin.Plugin; 16 import org.apache.ibatis.plugin.Signature; 17 18 / * 19 * interceptor function: automatically add operation attribute information to each entity object when it is added or modified. 20 * / 21 @ Intercepts ({@ Signature (type = Executor.class, method = "update", args = {MappedStatement.class, Object.class}) 22 public class OpeInfoInterceptor implements Interceptor 23 {24 25 public Object intercept (Invocation invocation) throws Throwable 26 {27 Object [] args = invocation.getArgs () 28 29 System.out.println ("- parameter interception--"); 30 System.out.println ("02 current thread ID:" + Thread.currentThread () .getId ()) 31 / / traversal handles all parameters. The update method has two parameters, as shown in the update () method in the Executor class. 32 for (int iTuno TX I