Browse Source

ConnectionFactory add paging intercepter (#1250)

pull/2/head
qiaozhanwei 5 years ago committed by lgcareer
parent
commit
dd7508a5e1
  1. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/config/MybatisPlusConfig.java
  2. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/ConnectionFactory.java

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/config/MybatisPlusConfig.java

@ -33,7 +33,7 @@ public class MybatisPlusConfig {
* @return pagination interceptor * @return pagination interceptor
*/ */
@Bean @Bean
public PaginationInterceptor paginationInterceptor() { public static PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor(); return new PaginationInterceptor();
} }

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/ConnectionFactory.java

@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.dao.config.MybatisPlusConfig;
import org.apache.ibatis.mapping.Environment; import org.apache.ibatis.mapping.Environment;
import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactory;
@ -122,6 +123,7 @@ public class ConnectionFactory {
configuration.setEnvironment(environment); configuration.setEnvironment(environment);
configuration.setLazyLoadingEnabled(true); configuration.setLazyLoadingEnabled(true);
configuration.addMappers("org.apache.dolphinscheduler.dao.mapper"); configuration.addMappers("org.apache.dolphinscheduler.dao.mapper");
configuration.addInterceptor(MybatisPlusConfig.paginationInterceptor());
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean(); MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
sqlSessionFactoryBean.setConfiguration(configuration); sqlSessionFactoryBean.setConfiguration(configuration);

Loading…
Cancel
Save