Ch00 record

10/10/2022 JavaMybatis

Mybatis 在使用returning(postgresql)返回值时,可以用select

 @Select("insert into organization(orgid,name,address) values(default,#{metadata.organization.name},#{metadata.organization.address}) returning orgid")
    @Options(flushCache = Options.FlushCachePolicy.TRUE)
    int createDocToOrganization(@Param("metadata") Metadata metadata, @Param("path") String path, @Param("objectId") String objectId);
1
2
3

# 数据分页

  1. maven依赖
<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>5.2.1</version>
</dependency>
1
2
3
4
5
  1. 在mybatis主配置文件中加入plugins,在environments之前
<!-- 
    plugins在配置文件中的位置必须符合要求,否则会报错,顺序如下:
    properties?, settings?, 
    typeAliases?, typeHandlers?, 
    objectFactory?,objectWrapperFactory?, 
    plugins?, 
    environments?, databaseIdProvider?, mappers?
-->
<plugins>
    <plugin interceptor="com.github.pagehelper.PageInterceptor">
    </plugin>
</plugins>

1
2
3
4
5
6
7
8
9
10
11
12
13

image-20230426010348519

# Cache 缓存

image-20230426010408798

image-20230426010419021

image-20230426010432635

image-20230426010442424

Last Updated: 11/19/2024, 1:54:38 PM