Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MyBatis interceptor: assigning values to parameter object properties

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report