All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.lingkang.mm.SqlSessionFactoryProxy Maven / Gradle / Ivy

Go to download

mybatis能力扩展框架,兼顾mybatis的mapper.xml编写操作数据库。

The newest version!
package top.lingkang.mm;

import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * SqlSessionFactory 代理
 *
 * @author lingkang
 * @create by 2024/3/4 16:29
 */
public class SqlSessionFactoryProxy implements InvocationHandler {

    private SqlSessionFactory sqlSessionFactory;

    public SqlSessionFactoryProxy(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (method.getReturnType() == Configuration.class)
            return sqlSessionFactory.getConfiguration();
        MagicSqlSession sqlSession = new MagicSqlSession(sqlSessionFactory, null);
        return sqlSession;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy