Created
January 8, 2019 16:56
-
-
Save circlee/c36963e8af7d8c304299c04d7b995ca1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public Object intercept(Invocation invocation) throws Throwable { | |
Object[] args = invocation.getArgs(); | |
MappedStatement ms = (MappedStatement)args[0]; | |
Object param = (Object)args[1]; | |
BoundSql boundSql = ms.getBoundSql(param); | |
List<ParameterMapping> parameterMappings = boundSql.getParameterMappings(); | |
TypeHandlerRegistry typeHandlerRegistry = ms.getConfiguration().getTypeHandlerRegistry(); | |
for (ParameterMapping parameterMapping : parameterMappings) { | |
if (parameterMapping.getMode() != ParameterMode.OUT) { | |
Object value; | |
String propertyName = parameterMapping.getProperty(); | |
if (boundSql.hasAdditionalParameter(propertyName)) { | |
value = boundSql.getAdditionalParameter(propertyName); | |
} else if (parameterObject == null) { | |
value = null; | |
} else if (typeHandlerRegistry.hasTypeHandler(parameterObject.getClass())) { | |
value = parameterObject; | |
} else { | |
MetaObject metaObject = configuration.newMetaObject(parameterObject); | |
value = metaObject.getValue(propertyName); | |
} | |
log.debug("value : {}" , value); | |
} | |
} | |
return invocation.proceed(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment