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

文章目录
  1. I. 项目搭建
    1. 1. 项目依赖
    2. 2. 数据准备
  2. II. 使用姿势
    1. 0. 基本准备
    2. 1. 主键查询
    3. 2. 查询指定字段
    4. 3. 列别名
    5. 4. 条件查询
    6. 5. in查询
    7. 6. between
    8. 7. like查询
    9. 8. null查询
    10. 9. 多查询条件
    11. 10. 排序
    12. 11. 分页
    13. 12. 测试输出
  3. II. 其他
    1. 0. 项目
    2. 1. 一灰灰Blog

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

I. 项目搭建

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

1. 项目依赖

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

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<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. 数据准备

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

II. 使用姿势

0. 基本准备

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
@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业务对象)

1
2
3
4
5
6
7
8
9
10
11
    /**
* 主键查询
*
* @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. 查询指定字段

1
2
3
4
5
6
7
8
9
10
11
/**
* 指定字段查询
*
* @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. 列别名

1
2
3
4
5
6
7
8
9
10
11
12
/**
* 列别名
*
* @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. 条件查询

条件比较查询

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
* 条件比较
*
* @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查询

1
2
3
4
5
6
7
8
9
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

1
2
3
4
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查询

1
2
3
4
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

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

9. 多查询条件

最简单的and/or查询

1
2
3
4
5
6
7
8
9
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. 排序

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

1
2
3
4
5
6
7
8
9
10
11
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. 分页

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
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或者有更好的建议,欢迎批评指正,不吝感激

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

一灰灰blog


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