13

【DB系列】Jooq之记录查询基础篇

 3 years ago
source link: http://spring.hhui.top/spring-blog/2020/12/03/201203-SpringBoot系列Jooq之记录查询基础篇/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

本文将主要介绍一下JOOQ查询篇的基本使用姿势,如果看完本文,会发现jooq的用法,和写sql基本上没啥两样

I. 项目搭建

本项目借助 SpringBoot 2.2.1.RELEASE + maven 3.5.3 + IDEA 进行开发

1. 项目依赖

关于如何创建一个SpringBoot的项目工程,不再本文的描述范围内,如有兴趣可以到文末的个人站点获取

在这个示例工程中,我们的选用h2dabase作为数据库(方便有兴趣的小伙伴直接获取工程源码之后,直接测试体验),因此对应的pom核心依赖如下

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jooq</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
    </dependency>
</dependencies>

2. 数据准备

本文对应的项目工程,和前面介绍增加删除的一致,所以这里直接使用之前新增的数据

00.jpg

II. 使用姿势

0. 基本准备

测试类,初始化一些必要的依赖,如 dsl

@Repository
public class PoetQueryRepository {
    private static final PoetTB poetTable = PoetTB.POET;
    private static final PoetryTB poetryTable = PoetryTB.POETRY;

    @Autowired
    private DSLContext dsl;

    private RecordMapper<PoetPO, PoetBO> poetMapper;
    private RecordMapper<PoetryPO, PoetryBO> poetryMapper;

    @PostConstruct
    public void init() {
        // 转换
        poetMapper = dsl.configuration().recordMapperProvider().provide(poetTable.recordType(), PoetBO.class);
        poetryMapper = dsl.configuration().recordMapperProvider().provide(poetryTable.recordType(), PoetryBO.class);
    }
}

1. 主键查询

请注意下面的 poetMapper.map ,将record实体(包含数据库基本信息)转换为业务实体(POJO业务对象)

    /**
     * 主键查询
     *
     * @param id
     * @return
     */
    public PoetBO queryById(int id) {
        // select * from poet where id = xxx
        return poetMapper.map(dsl.selectFrom(poetTable).where(poetTable.ID.eq(id)).fetchOne());
    }
}

2. 查询指定字段

/**
 * 指定字段查询
 *
 * @param id
 * @return
 */
public String queryFieldsById(int id) {
    // select `name` from poet where id = xxx
    Record1<String> record = dsl.select(poetTable.NAME).from(poetTable).where(poetTable.ID.eq(id)).fetchOne();
    return record.get(poetTable.NAME);
}

3. 列别名

/**
 * 列别名
 *
 * @param id
 * @return
 */
public String queryFieldsById2(int id) {
    // select `name` as author from poet where id = xxx
    Record1<String> record =
            dsl.select(poetTable.NAME.as("author")).from(poetTable).where(poetTable.ID.eq(id)).fetchOne();
    return (String) record.get("author");
}

4. 条件查询

条件比较查询

/**
 * 条件比较
 *
 * @param id
 * @return
 */
public List<PoetBO> queryByNotEq(int id) {
    // select * from poet where id != xxx
    return dsl.selectFrom(poetTable).where(poetTable.ID.notEqual(id)).fetch().map(poetMapper);
}

public List<PoetBO> queryByIdGT(int id) {
    // select * from poet where id > xxx
    return dsl.selectFrom(poetTable).where(poetTable.ID.gt(id)).fetch().map(poetMapper);
}

public List<PoetBO> queryByIdGE(int id) {
    // select * from poet where id >= xxx
    return dsl.selectFrom(poetTable).where(poetTable.ID.ge(id)).fetch().map(poetMapper);
}

public List<PoetBO> queryByIdLT(int id) {
    // select * from poet where id < xxx
    return dsl.selectFrom(poetTable).where(poetTable.ID.lt(id)).fetch().map(poetMapper);
}

5. in查询

in / not 查询,原则上如非必要,一般不推荐是用not in查询

public List<PoetBO> queryByIdIn(List<Integer> ids) {
    // select * from poet where id in (xxx)
    return dsl.selectFrom(poetTable).where(poetTable.ID.in(ids)).fetch().map(poetMapper);
}

public List<PoetBO> queryByIdNotIn(List<Integer> ids) {
    // select * from poet where id not in (xxx)
    return dsl.selectFrom(poetTable).where(poetTable.ID.notIn(ids)).fetch().map(poetMapper);
}

6. between

public List<PoetBO> queryByIdBetween(int left, int right) {
    // select * from poet where id between a and b
    return dsl.selectFrom(poetTable).where(poetTable.ID.between(left, right)).fetch(poetMapper);
}

7. like查询

public List<PoetBO> queryByNameLike(String name) {
    // select * from poet where name like '%xxx%'
    return dsl.selectFrom(poetTable).where(poetTable.NAME.like("%" + name + " %")).fetch(poetMapper);
}

8. null查询

原则上,字段不建议支持null

public List<PoetBO> queryByNameIsNull() {
    // select * from poet where name is null;
    return dsl.selectFrom(poetTable).where(poetTable.NAME.isNull()).fetch(poetMapper);
}

9. 多查询条件

最简单的and/or查询

public PoetBO queryByIdAndName(int id, String name) {
    // select * from poet where name = xxx and id = xxx
    return dsl.selectFrom(poetTable).where(poetTable.ID.eq(id)).and(poetTable.NAME.eq(name)).fetchOne(poetMapper);
}

public List<PoetBO> queryByIdOrName(int id, String name) {
    // select * from poet where name = xxx or id = xxx
    return dsl.selectFrom(poetTable).where(poetTable.ID.eq(id)).or(poetTable.NAME.eq(name)).fetch(poetMapper);
}

10. 排序

请注意下多字段的排序使用姿势

public List<PoetryBO> queryByIdGtOrderByIdDesc(int id) {
    return dsl.selectFrom(poetryTable).where(poetryTable.ID.gt(id)).orderBy(poetryTable.ID.desc())
            .fetch(poetryMapper);
}

public List<PoetryBO> queryByIdGtOrderByPoetIdAndId(int id) {
    // 双字段的排序
    // select * from poetry where id > xxx order by poet_id asc, id asc
    return dsl.selectFrom(poetryTable).where(poetryTable.ID.gt(id))
            .orderBy(poetryTable.POET_ID.asc(), poetryTable.ID.asc()).fetch(poetryMapper);
}

11. 分页

public List<PoetryBO> queryLimit(int limit) {
    // select * from poetry limit xxx
    return dsl.selectFrom(poetryTable).limit(limit).fetch(poetryMapper);
}

public List<PoetryBO> queryLimit(int offset, int limit) {
    // select * from poetry limit xxx, xxx
    return dsl.selectFrom(poetryTable).limit(offset, limit).fetch(poetryMapper);
}

public List<PoetryBO> queryOffset(int offset, int limit) {
    // select * from poetry limit xxx, xxx
    return dsl.selectFrom(poetryTable).offset(offset).limit(limit).fetch(poetryMapper);
}

12. 测试输出

完整的测试输出如下,我们也开启了jooq的debug日志,因此可以看到最终真实执行的ip地址

DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" = cast(? as int)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" = 1
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   1|李白  |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 1
PoetBO (1, 李白)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" = cast(? as int)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" = 1
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |NAME|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |李白  |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 1
李白
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."NAME" "author" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" = cast(? as int)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."NAME" "author" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" = 1
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |author|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |李白    |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 1
李白
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" <> cast(? as int)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" <> 1
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME   |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|艾可翁    |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  11|一灰     |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  12|一灰灰    |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  13|一灰灰Blog|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  14|yh     |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |...record(s) truncated...
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 10
[PoetBO (2, 艾可翁), PoetBO (11, 一灰), PoetBO (12, 一灰灰), PoetBO (13, 一灰灰Blog), PoetBO (14, yh), PoetBO (15, yhh), PoetBO (16, yihui), PoetBO (17, yihuihui), PoetBO (18, YiHui), PoetBO (19, YiHuiBlog)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" > cast(? as int)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" > 1
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME   |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|艾可翁    |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  11|一灰     |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  12|一灰灰    |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  13|一灰灰Blog|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  14|yh     |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |...record(s) truncated...
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 10
[PoetBO (2, 艾可翁), PoetBO (11, 一灰), PoetBO (12, 一灰灰), PoetBO (13, 一灰灰Blog), PoetBO (14, yh), PoetBO (15, yhh), PoetBO (16, yihui), PoetBO (17, yihuihui), PoetBO (18, YiHui), PoetBO (19, YiHuiBlog)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" >= cast(? as int)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" >= 1
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME   |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   1|李白     |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|艾可翁    |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  11|一灰     |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  12|一灰灰    |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  13|一灰灰Blog|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |...record(s) truncated...
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 11
[PoetBO (1, 李白), PoetBO (2, 艾可翁), PoetBO (11, 一灰), PoetBO (12, 一灰灰), PoetBO (13, 一灰灰Blog), PoetBO (14, yh), PoetBO (15, yhh), PoetBO (16, yihui), PoetBO (17, yihuihui), PoetBO (18, YiHui), PoetBO (19, YiHuiBlog)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" < cast(? as int)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" < 2
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   1|李白  |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 1
[PoetBO (1, 李白)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" in (cast(? as int), cast(? as int), cast(? as int))
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" in (1, 2, 3)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   1|李白  |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|艾可翁 |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 2
[PoetBO (1, 李白), PoetBO (2, 艾可翁)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" not in (cast(? as int), cast(? as int), cast(? as int))
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" not in (1, 2, 3)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME   |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  11|一灰     |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  12|一灰灰    |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  13|一灰灰Blog|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  14|yh     |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  15|yhh    |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |...record(s) truncated...
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 9
[PoetBO (11, 一灰), PoetBO (12, 一灰灰), PoetBO (13, 一灰灰Blog), PoetBO (14, yh), PoetBO (15, yhh), PoetBO (16, yihui), PoetBO (17, yihuihui), PoetBO (18, YiHui), PoetBO (19, YiHuiBlog)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" between cast(? as int) and cast(? as int)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."ID" between 1 and 4
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   1|李白  |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|艾可翁 |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 2
[PoetBO (1, 李白), PoetBO (2, 艾可翁)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."NAME" like cast(? as varchar)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."NAME" like '%白 %'
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 0
[]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where "PUBLIC"."POET"."NAME" is null
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 0
[]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where ("PUBLIC"."POET"."ID" = cast(? as int) and "PUBLIC"."POET"."NAME" = cast(? as varchar))
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where ("PUBLIC"."POET"."ID" = 1 and "PUBLIC"."POET"."NAME" = '李白')
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   1|李白  |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 1
PoetBO (1, 李白)
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where ("PUBLIC"."POET"."ID" = cast(? as int) or "PUBLIC"."POET"."NAME" = cast(? as varchar))
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POET"."ID", "PUBLIC"."POET"."NAME" from "PUBLIC"."POET" where ("PUBLIC"."POET"."ID" = 1 or "PUBLIC"."POET"."NAME" = '一灰')
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|NAME|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   1|李白  |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  11|一灰  |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+----+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 2
[PoetBO (1, 李白), PoetBO (11, 一灰)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" where "PUBLIC"."POETRY"."ID" > cast(? as int) order by "PUBLIC"."POETRY"."ID" desc
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" where "PUBLIC"."POETRY"."ID" > 1 order by "PUBLIC"."POETRY"."ID" desc
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|POET_ID|TITLE|CONTENT                                           |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   4|      2|番阳道中 |督府春移檄,江城昼撤花。\n好书如隔世,久客似无家。\n畏路多言虎,荒村半是鸦。\n道逢西北客...|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   3|      2|钓台   |云台历历纪功臣,底事中间有子陵。\n未必故人同卧处,了无一语及中兴。                |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|      1|落日忆山中|雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去...|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 3
[PoetryBO (4, 2, 番阳道中, 督府春移檄,江城昼撤花。\n好书如隔世,久客似无家。\n畏路多言虎,荒村半是鸦。\n道逢西北客,挥泪问京华。), PoetryBO (3, 2, 钓台, 云台历历纪功臣,底事中间有子陵。\n未必故人同卧处,了无一语及中兴。), PoetryBO (2, 1, 落日忆山中, 雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去,学道飞丹砂。)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" where "PUBLIC"."POETRY"."ID" > cast(? as int) order by "PUBLIC"."POETRY"."POET_ID" asc, "PUBLIC"."POETRY"."ID" asc
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" where "PUBLIC"."POETRY"."ID" > 1 order by "PUBLIC"."POETRY"."POET_ID" asc, "PUBLIC"."POETRY"."ID" asc
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|POET_ID|TITLE|CONTENT                                           |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|      1|落日忆山中|雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去...|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   3|      2|钓台   |云台历历纪功臣,底事中间有子陵。\n未必故人同卧处,了无一语及中兴。                |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   4|      2|番阳道中 |督府春移檄,江城昼撤花。\n好书如隔世,久客似无家。\n畏路多言虎,荒村半是鸦。\n道逢西北客...|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 3
[PoetryBO (2, 1, 落日忆山中, 雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去,学道飞丹砂。), PoetryBO (3, 2, 钓台, 云台历历纪功臣,底事中间有子陵。\n未必故人同卧处,了无一语及中兴。), PoetryBO (4, 2, 番阳道中, 督府春移檄,江城昼撤花。\n好书如隔世,久客似无家。\n畏路多言虎,荒村半是鸦。\n道逢西北客,挥泪问京华。)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" limit ?
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" limit 2
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|POET_ID|TITLE|CONTENT                                           |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   1|      1|咏桂   |世人种桃李,皆在金张门。\n攀折争捷径,及此春风暄。\n一朝天霜下,荣耀难久存。\n安知南山桂...|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|      1|落日忆山中|雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去...|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 2
[PoetryBO (1, 1, 咏桂, 世人种桃李,皆在金张门。\n攀折争捷径,及此春风暄。\n一朝天霜下,荣耀难久存。\n安知南山桂,绿叶垂芳根。\n清阴亦可托,何惜树君园。), PoetryBO (2, 1, 落日忆山中, 雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去,学道飞丹砂。)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" limit ? offset ?
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" limit 2 offset 1
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|POET_ID|TITLE|CONTENT                                           |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|      1|落日忆山中|雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去...|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   3|      2|钓台   |云台历历纪功臣,底事中间有子陵。\n未必故人同卧处,了无一语及中兴。                |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 2
[PoetryBO (2, 1, 落日忆山中, 雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去,学道飞丹砂。), PoetryBO (3, 2, 钓台, 云台历历纪功臣,底事中间有子陵。\n未必故人同卧处,了无一语及中兴。)]
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Executing query          : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" limit ? offset ?
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : -> with bind values      : select "PUBLIC"."POETRY"."ID", "PUBLIC"."POETRY"."POET_ID", "PUBLIC"."POETRY"."TITLE", "PUBLIC"."POETRY"."CONTENT" from "PUBLIC"."POETRY" limit 2 offset 1
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched result           : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |  ID|POET_ID|TITLE|CONTENT                                           |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   2|      1|落日忆山中|雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去...|
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : |   3|      2|钓台   |云台历历纪功臣,底事中间有子陵。\n未必故人同卧处,了无一语及中兴。                |
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            :                          : +----+-------+-----+--------------------------------------------------+
DEBUG 10420 --- [io-8080-exec-10] org.jooq.tools.LoggerListener            : Fetched row(s)           : 2
[PoetryBO (2, 1, 落日忆山中, 雨后烟景绿,晴天散馀霞。\n东风随春归,发我枝上花。\n花落时欲暮,见此令人嗟。\n愿游名山去,学道飞丹砂。), PoetryBO (3, 2, 钓台, 云台历历纪功臣,底事中间有子陵。\n未必故人同卧处,了无一语及中兴。)]

II. 其他

0. 项目

系列博文

项目源码

1. 一灰灰Blog

尽信书则不如,以上内容,纯属一家之言,因个人能力有限,难免有疏漏和错误之处,如发现bug或者有更好的建议,欢迎批评指正,不吝感激

下面一灰灰的个人博客,记录所有学习和工作中的博文,欢迎大家前去逛逛

info.png

打赏 如果觉得我的文章对您有帮助,请随意打赏。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK