Hello Edurado,
I decided to implement MyBatis plugin.
@Intercepts({ @Signature(type = Executor.class, method = "update",
args = {MappedStatement.class, Object.class }) })
@Override
public Object intercept(Invocation invocation) throws Throwable {
long start = System.currentTimeMillis();
System.out.println("START intercept " + start);
Object proceed = invocation.proceed();
System.out.println("END intercept " + (System.currentTimeMillis() -
start));
return proceed;
}
It works fine for me only for update, when I change method = "query" I
have got
org.apache.ibatis.exceptions.PersistenceException:
### Error opening session. Cause:
org.apache.ibatis.plugin.PluginException: Could not find method on
interface org.apache.ibatis.executor.Executor named query. Cause:
java.lang.NoSuchMethodException:
org.apache.ibatis.executor.Executor.query(org.apache.ibatis.mapping.MappedStatement,
java.lang.Object)
### The error may exist in .....Mapper.xml
### Cause: org.apache.ibatis.plugin.PluginException: Could not find
method on interface org.apache.ibatis.executor.Executor named query.
Cause: java.lang.NoSuchMethodException:
org.apache.ibatis.executor.Executor.query(org.apache.ibatis.mapping.MappedStatement,
java.lang.Object)
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:
8)
at
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromConnection(DefaultSqlSessionFactory.java:
104)
at
org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSession(DefaultSqlSessionFactory.java:
60)
at
org.mybatis.spring.SqlSessionUtils.getSqlSession(SqlSessionUtils.java:
134)
at org.mybatis.spring.SqlSessionTemplate
$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:333)
at $Proxy5.selectList(Unknown Source)
at
org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:
189)
at
org.apache.ibatis.binding.MapperMethod.executeForList(MapperMethod.java:
85)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:
65)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:38)
at $Proxy6.selectByLogin(Unknown Source)
Mapper.xml
<select id="selectByLogin" parameterType="String"
resultMap="BaseResultMap">
select * from USERS_RIGHTS
where
login = #{value}
</select>
Thx for reply