@Signature(type=org.apache.ibatis.executor.Executor.class,method="update",args={org.apache.ibatis.mapping.MappedStatement.class,java.lang.Object.class}) @Signature(type=org.apache.ibatis.executor.Executor.class,method="query",args={org.apache.ibatis.mapping.MappedStatement.class,java.lang.Object.class,org.apache.ibatis.session.RowBounds.class,org.apache.ibatis.session.ResultHandler.class}) @Signature(type=org.apache.ibatis.executor.Executor.class,method="query",args={org.apache.ibatis.mapping.MappedStatement.class,java.lang.Object.class,org.apache.ibatis.session.RowBounds.class,org.apache.ibatis.session.ResultHandler.class,org.apache.ibatis.cache.CacheKey.class,org.apache.ibatis.mapping.BoundSql.class})
public class DynamicResultMappingInterceptor
extends Object
implements org.apache.ibatis.plugin.Interceptor
该拦截器用于在执行 INSERT 操作时动态判断是否需要开启 useGeneratedKeys, 并根据实体类中的自增列信息构建新的 MappedStatement 来替换原始语句。
| 构造器和说明 |
|---|
DynamicResultMappingInterceptor() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected Class<?> |
findDeclaredEntityClass(Method mapperMethod,
Class<?> mapperType)
获取 Mapper 接口或方法上声明的实体类。
|
Object |
intercept(org.apache.ibatis.plugin.Invocation invocation)
拦截 MyBatis 执行过程,在 INSERT 操作中动态启用 useGeneratedKeys。
|
Object |
plugin(Object target) |
void |
setProperties(Properties properties) |
public Object intercept(org.apache.ibatis.plugin.Invocation invocation) throws Throwable
intercept 在接口中 org.apache.ibatis.plugin.Interceptorinvocation - 调用上下文对象Throwable - 若发生错误则向上抛出protected Class<?> findDeclaredEntityClass(Method mapperMethod, Class<?> mapperType)
mapperMethod - 当前调用的方法对象mapperType - Mapper 接口类型IllegalStateException - 如果无法确定实体类则抛出异常public void setProperties(Properties properties)
setProperties 在接口中 org.apache.ibatis.plugin.InterceptorCopyright © 2025 fossc. All rights reserved.