Search in sources :

Example 1 with SqlRunnerInjector

use of com.baomidou.mybatisplus.core.injector.SqlRunnerInjector in project solon by noear.

the class MybatisSqlSessionFactoryBuilderNew method build.

@Override
public SqlSessionFactory build(Configuration configuration) {
    GlobalConfig globalConfig = GlobalConfigUtils.getGlobalConfig(configuration);
    Object identifierGenerator;
    if (null == globalConfig.getIdentifierGenerator()) {
        identifierGenerator = new DefaultIdentifierGenerator();
        globalConfig.setIdentifierGenerator((IdentifierGenerator) identifierGenerator);
    } else {
        identifierGenerator = globalConfig.getIdentifierGenerator();
    }
    IdWorker.setIdentifierGenerator((IdentifierGenerator) identifierGenerator);
    if (globalConfig.isEnableSqlRunner()) {
        (new SqlRunnerInjector()).inject(configuration);
    }
    SqlSessionFactory sqlSessionFactory = super.build(configuration);
    globalConfig.setSqlSessionFactory(sqlSessionFactory);
    Aop.getAsyn(MetaObjectHandler.class, bw -> {
        globalConfig.setMetaObjectHandler(bw.get());
    });
    return sqlSessionFactory;
}
Also used : SqlRunnerInjector(com.baomidou.mybatisplus.core.injector.SqlRunnerInjector) GlobalConfig(com.baomidou.mybatisplus.core.config.GlobalConfig) SqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory) DefaultIdentifierGenerator(com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator)

Aggregations

GlobalConfig (com.baomidou.mybatisplus.core.config.GlobalConfig)1 DefaultIdentifierGenerator (com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator)1 SqlRunnerInjector (com.baomidou.mybatisplus.core.injector.SqlRunnerInjector)1 SqlSessionFactory (org.apache.ibatis.session.SqlSessionFactory)1