Search in sources :

Example 56 with MybatisPlusInterceptor

use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project Hidoc by yuzhengyang.

the class MybatisPlusConfig method mybatisPlusInterceptor.

/**
 * 3.4.2 版本新分页插件
 * 一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)
 */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
    return interceptor;
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) Bean(org.springframework.context.annotation.Bean)

Example 57 with MybatisPlusInterceptor

use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project spring-boot-demo by fengwenyi.

the class MyBatisPlusConfig method mybatisPlusInterceptor.

@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    final MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    // 分页插件
    interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
    return interceptor;
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) Bean(org.springframework.context.annotation.Bean)

Example 58 with MybatisPlusInterceptor

use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project boot-admin by hb0730.

the class MybatisPlusConfig method mybatisPlusInterceptor.

/**
 * 注册MybatisPlusInterceptor
 *
 * @return MybatisPlusInterceptor
 */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    interceptor.addInnerInterceptor(paginationInnerInterceptor());
    // 乐观锁
    interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
    // 击 SQL 阻断解析器,防止全表更新与删除
    interceptor.addInnerInterceptor(new BlockAttackInnerInterceptor());
    return interceptor;
}
Also used : BlockAttackInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor) MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) OptimisticLockerInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor) Bean(org.springframework.context.annotation.Bean)

Example 59 with MybatisPlusInterceptor

use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project quarkus-mybatis by quarkiverse.

the class MyBatisPlusRecorder method initSqlSession.

public void initSqlSession(RuntimeValue<SqlSessionFactory> sqlSessionFactory, MyBatisPlusConfig config) {
    if (config.pageEnabled) {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        sqlSessionFactory.getValue().getConfiguration().addInterceptor(interceptor);
    }
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)

Example 60 with MybatisPlusInterceptor

use of com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor in project platform by elveahuang.

the class CustomMyBatisAutoConfiguration method mybatisPlusInterceptor.

/**
 * MyBatis自定义配置
 */
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
    return interceptor;
}
Also used : MybatisPlusInterceptor(com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor) PaginationInnerInterceptor(com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

MybatisPlusInterceptor (com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor)113 Bean (org.springframework.context.annotation.Bean)110 PaginationInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor)94 OptimisticLockerInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor)18 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)15 BlockAttackInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor)13 TenantLineInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor)7 TenantLineHandler (com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler)4 InnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.InnerInterceptor)4 Order (org.springframework.core.annotation.Order)4 MybatisSqlSessionFactoryBean (com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean)3 Expression (net.sf.jsqlparser.expression.Expression)3 LongValue (net.sf.jsqlparser.expression.LongValue)3 MybatisConfiguration (com.baomidou.mybatisplus.core.MybatisConfiguration)2 IllegalSQLInnerInterceptor (com.baomidou.mybatisplus.extension.plugins.inner.IllegalSQLInnerInterceptor)2 StringValue (net.sf.jsqlparser.expression.StringValue)2 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)2 ConditionalOnExpression (org.springframework.boot.autoconfigure.condition.ConditionalOnExpression)2 TenantLineHandler (com.albedo.java.plugins.database.handler.TenantLineHandler)1 SchemaInterceptor (com.albedo.java.plugins.database.interceptor.SchemaInterceptor)1