1.分页配置
因为神通数据库与ORACLE数据库高度兼容,所以可以使用ORACLE的分页配置,配置如下:
/**
* 分页插件
*
* @return PaginationInterceptor
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor().setDialectType("oracle");
}
2.主键自增策略
MP默认的插入返回的ID有问题,因此我们需要做下主键自增策略以获得正确的ID值。
1. yml配置
# mybaits 模块配置
mybatis-plus:
configuration:
jdbc-type-for-null: 'null' #注意:单引号
global-config:
id-type: 0
key-generator: com.baomidou.mybatisplus.incrementer.OracleKeyGenerator
refresh-mapper: true
db-config:
db-type: oracle
2. 实体类配置
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("resrc")
@KeySequence(value = "resrc_id_seq")
public class Resrc extends Model<Resrc> {
/**
* ID
*/
@TableId(type = IdType.INPUT)
private Long id;
..................
}
@KeySequence(value = “resrc_id_seq”)和@TableId(type = IdType.INPUT)是核心注解,不要漏掉哦!@KeySequence(value = “resrc_id_seq”)里的value值是对应表的序列。
3.总结
关于神通数据库mybatis-plus的配置到此就告一段落了,有意见的小伙伴留言哦!