Search in sources :

Example 21 with GlobalConfig

use of com.baomidou.mybatisplus.core.config.GlobalConfig in project dolphinscheduler by apache.

the class SpringConnectionFactory method sqlSessionFactory.

/**
 * * get sql session factory
 * @return sqlSessionFactory
 * @throws Exception sqlSessionFactory exception
 */
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
    MybatisConfiguration configuration = new MybatisConfiguration();
    configuration.setMapUnderscoreToCamelCase(true);
    configuration.setCacheEnabled(false);
    configuration.setCallSettersOnNulls(true);
    configuration.setJdbcTypeForNull(JdbcType.NULL);
    configuration.addInterceptor(paginationInterceptor());
    MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
    sqlSessionFactoryBean.setConfiguration(configuration);
    sqlSessionFactoryBean.setDataSource(dataSource());
    GlobalConfig.DbConfig dbConfig = new GlobalConfig.DbConfig();
    dbConfig.setIdType(IdType.AUTO);
    GlobalConfig globalConfig = new GlobalConfig();
    globalConfig.setDbConfig(dbConfig);
    sqlSessionFactoryBean.setGlobalConfig(globalConfig);
    sqlSessionFactoryBean.setTypeAliasesPackage("org.apache.dolphinscheduler.dao.entity");
    ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(resolver.getResources("org/apache/dolphinscheduler/dao/mapper/*Mapper.xml"));
    sqlSessionFactoryBean.setTypeEnumsPackage("org.apache.dolphinscheduler.*.enums");
    return sqlSessionFactoryBean.getObject();
}
Also used : MybatisSqlSessionFactoryBean(com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ResourcePatternResolver(org.springframework.core.io.support.ResourcePatternResolver) MybatisConfiguration(com.baomidou.mybatisplus.core.MybatisConfiguration) GlobalConfig(com.baomidou.mybatisplus.core.config.GlobalConfig) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) MybatisSqlSessionFactoryBean(com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

GlobalConfig (com.baomidou.mybatisplus.core.config.GlobalConfig)21 MybatisSqlSessionFactoryBean (com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean)13 Bean (org.springframework.context.annotation.Bean)12 MybatisConfiguration (com.baomidou.mybatisplus.core.MybatisConfiguration)10 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)7 Resource (org.springframework.core.io.Resource)4 ResourcePatternResolver (org.springframework.core.io.support.ResourcePatternResolver)4 DbType (com.baomidou.mybatisplus.annotation.DbType)2 IKeyGenerator (com.baomidou.mybatisplus.core.incrementer.IKeyGenerator)2 MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)2 PaginationInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)2 SqlSessionFactory (org.apache.ibatis.session.SqlSessionFactory)2 FieldFill (com.baomidou.mybatisplus.annotation.FieldFill)1 ConfigurationCustomizer (com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer)1 DefaultIdentifierGenerator (com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator)1 AbstractMethod (com.baomidou.mybatisplus.core.injector.AbstractMethod)1 DefaultSqlInjector (com.baomidou.mybatisplus.core.injector.DefaultSqlInjector)1 SqlRunnerInjector (com.baomidou.mybatisplus.core.injector.SqlRunnerInjector)1 TableInfo (com.baomidou.mybatisplus.core.metadata.TableInfo)1 MybatisMapWrapperFactory (com.baomidou.mybatisplus.extension.MybatisMapWrapperFactory)1