how to let joinPoint proceed Wrapper which is transferred by selectOne in mybatis's baseMapper?

20 Views Asked by At

I define java aop for my logic. If it is the instance of Wrapper, nothing will be done extrally.

However, it thorw the exception below
nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ew' in 'class com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper'

After google, i add the @Param(Constants.WRAPPER) in BasePrivateDataMapper which doesn't help.

I have the workaround but still curious for this case.

@Mapper
public interface BasePrivateDataMapper<T> extends BaseMapper<T> {    
    @Override
    @PrivateDataCommonAnnotation
    default T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper) {
        return BaseMapper.super.selectOne(queryWrapper);
    }
}


@Around("pointCut()")
public Object encodeAroundAdvice(ProceedingJoinPoint joinPoint) {
    Object returnVal = null;
    Object[] args = joinPoint.getArgs();
    try {
        if(args != null && args.length != 0){
            if(!(args[0] instanceof AbstractWrapper)){
            ...
            }
        }

        returnVal = joinPoint.proceed(args);
    } catch (Throwable e) {
        log.error("fail to handle private data since {}", e.getMessage());
    }
    return handleResult(returnVal, args);
}
0

There are 0 best solutions below