mybatis拦截器执行原理
mybatis的拦截器本人平时也很少用到,没了解之前,也只是知道运用到了动态代理用来增强方法的功能,但是不了解其中的原理。为了更好的使用mybatis,这次,我记录下我所了解的mybatis的原理,本文不一定完全正确,可能有理解不到位的地方。 ...
mybatis的拦截器本人平时也很少用到,没了解之前,也只是知道运用到了动态代理用来增强方法的功能,但是不了解其中的原理。为了更好的使用mybatis,这次,我记录下我所了解的mybatis的原理,本文不一定完全正确,可能有理解不到位的地方。 ...
java日志体系 常用日志框架 Log4j:Apache Log4j是一个基于Java的日志记录工具。它是由Ceki Gülcü首创的,现在则是Apache软件基金会的一个项目。 Log4j 2:Apache Log4j 2是Apache开发的一款Log4j的升级产品。 Commons Logging:Apache基金会所属的项目,是一套Java日志接口,之前叫Jakarta Commons Logging,后更名为Commons Logging。Apache推出了JCL(Jakarta Commons Logging),它只是定义了一套日志接口(其内部也提供一个Simple Log的简单实现),JCL也是一套接口规范,支持运行时动态加载日志组件的实现。也就是说,在应用程序代码中,只需调用Commons Logging的接口,底层实现可以是Log4j,也可以是JUL SLF4J:全称为Simple Logging Facade for Java,类似于Commons Logging,是一套简易Java日志门面,本身并无日志的实现。 Logback:是一套日志组件的实现,属于SLF4J阵营。 JUL:全称是Java Util Logging,是JDK1.4以后提供的日志实现。 ...
mybatis的缓存 首先来看下mybatis对缓存的规范,规范嘛就是定义的接口啦。 缓存接口 Cache接口 定义了缓存的方法 public interface Cache { /**获取缓存的id * @return The identifier of this cache */ String getId(); /**添加缓存 * @param key Can be any object but usually it is a {@link CacheKey} * @param value The result of a select. */ void putObject(Object key, Object value); /**根据缓存键获取缓存 * @param key The key * @return The object stored in the cache. */ Object getObject(Object key); /**移除缓存 * As of 3.3.0 this method is only called during a rollback * for any previous value that was missing in the cache. * This lets any blocking cache to release the lock that * may have previously put on the key. * A blocking cache puts a lock when a value is null * and releases it when the value is back again. * This way other threads will wait for the value to be * available instead of hitting the database. * * * @param key The key * @return Not used */ Object removeObject(Object key); /** * Clears this cache instance */ void clear(); /** * Optional. This method is not called by the core. * * @return The number of elements stored in the cache (not its capacity). */ int getSize(); /** * Optional. As of 3.2.6 this method is no longer called by the core. * * Any locking needed by the cache must be provided internally by the cache provider. * * @return A ReadWriteLock */ ReadWriteLock getReadWriteLock(); } 实现 ...
sequenceDiagram participant SqlSession participant Excutor participant StatementHandler participant parameterHandler participant ResultSetHandler participant TypeHandler participant ResultSet participant JDBC SqlSession->>Excutor: Excutor->>StatementHandler: StatementHandler-->>parameterHandler: StatementHandler-->>JDBC: parameterHandler-->>TypeHandler: parameterHandler->>JDBC: JDBC->>ResultSet: ResultSet-->>TypeHandler: ResultSet-->>ResultSetHandler: TypeHandler-->>ResultSetHandler: ResultSetHandler->>StatementHandler: StatementHandler->>Excutor: Excutor->>SqlSession: Note left of SqlSession: asa flowchart TD subgraph configuration mappedStatement1 --> mappedStatement2 end configuration: ...