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

orm.benchmark.plus.Init Maven / Gradle / Ivy

package orm.benchmark.plus;


import com.baomidou.mybatisplus.core.MybatisConfiguration;
import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
import orm.benchmark.datasource.DataSourceFactory;
import orm.benchmark.plus.mapper.PlusSysUserMapper;


public class Init {

    private static final SqlSessionFactory sqlSessionFactory;

    static {
        Environment environment = new Environment("test", new JdbcTransactionFactory(), DataSourceFactory.getDataSource());
        Configuration configuration = new MybatisConfiguration(environment);
        //configuration.setLogImpl(StdOutImpl.class);
        configuration.addMapper(PlusSysUserMapper.class);
        sqlSessionFactory = new SqlSessionFactoryBuilder()
                .build(configuration);
    }

    public static SqlSession getSqlSession() {
        return sqlSessionFactory.openSession();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy