Search in sources :

Example 1 with IKeyGenerator

use of com.baomidou.mybatisplus.core.incrementer.IKeyGenerator in project mybatis-plus-samples by baomidou.

the class MpConfig method globalConfiguration.

@Bean
public GlobalConfig globalConfiguration() {
    GlobalConfig conf = new GlobalConfig();
    conf.setDbConfig(new GlobalConfig.DbConfig().setKeyGenerators(Arrays.asList(// h2 1.x 的写法(默认 2.x 的写法)
    new IKeyGenerator() {

        @Override
        public String executeSql(String incrementerName) {
            return "select " + incrementerName + ".nextval";
        }

        @Override
        public DbType dbType() {
            return DbType.POSTGRE_SQL;
        }
    })));
    return conf;
}
Also used : GlobalConfig(com.baomidou.mybatisplus.core.config.GlobalConfig) IKeyGenerator(com.baomidou.mybatisplus.core.incrementer.IKeyGenerator) DbType(com.baomidou.mybatisplus.annotation.DbType) Bean(org.springframework.context.annotation.Bean)

Example 2 with IKeyGenerator

use of com.baomidou.mybatisplus.core.incrementer.IKeyGenerator in project mybatis-plus-samples by baomidou.

the class DbConfigurations method globalConfiguration.

@Bean
public GlobalConfig globalConfiguration() {
    GlobalConfig conf = new GlobalConfig();
    conf.setDbConfig(new GlobalConfig.DbConfig().setKeyGenerators(Arrays.asList(// h2 1.x 的写法(默认 2.x 的写法)
    new IKeyGenerator() {

        @Override
        public String executeSql(String incrementerName) {
            return "select " + incrementerName + ".nextval";
        }

        @Override
        public DbType dbType() {
            return DbType.POSTGRE_SQL;
        }
    })));
    return conf;
}
Also used : GlobalConfig(com.baomidou.mybatisplus.core.config.GlobalConfig) IKeyGenerator(com.baomidou.mybatisplus.core.incrementer.IKeyGenerator) DbType(com.baomidou.mybatisplus.annotation.DbType) Bean(org.springframework.context.annotation.Bean)

Aggregations

DbType (com.baomidou.mybatisplus.annotation.DbType)2 GlobalConfig (com.baomidou.mybatisplus.core.config.GlobalConfig)2 IKeyGenerator (com.baomidou.mybatisplus.core.incrementer.IKeyGenerator)2 Bean (org.springframework.context.annotation.Bean)2