Skip to content

Commit f07b868

Browse files
committed
Doc and test updates
1 parent 90228b6 commit f07b868

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/site/markdown/docs/whereClauses.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ You can use the where clause support on its own if you would rather code your ow
7878
"${whereClause}"
7979
})
8080
@ResultMap("AnimalDataResult")
81-
List<AnimalData> selectByExample(WhereClauseAndParameters whereClause);
81+
List<AnimalData> selectByExample(WhereClauseProvider whereClause);
8282
```
8383

8484
You can build a stand alone where clause and call your mapper like this:
8585

8686
```java
87-
WhereClauseAndParameters whereClause = where(id, isNotBetween(10).and(60))
87+
WhereClauseProvider whereClause = where(id, isNotBetween(10).and(60))
8888
.build()
8989
.render(RenderingStrategy.MYBATIS3);
9090

@@ -102,12 +102,12 @@ If you need to use a table alias in the generated where clause you can supply it
102102
"${whereClause}"
103103
})
104104
@ResultMap("AnimalDataResult")
105-
List<AnimalData> selectByExampleWithAlias(WhereClauseAndParameters whereClause);
105+
List<AnimalData> selectByExampleWithAlias(WhereClauseProvider whereClause);
106106
```
107107
Then you can specify the alias for the generated WHERE clause on the render method like this:
108108

109109
```java
110-
WhereClauseAndParameters whereClause = where(id, isEqualTo(1), or(bodyWeight, isGreaterThan(1.0)))
110+
WhereClauseProvider whereClause = where(id, isEqualTo(1), or(bodyWeight, isGreaterThan(1.0)))
111111
.build()
112112
.render(RenderingStrategy.MYBATIS3, TableAliasCalculator.of(animalData, "a"));
113113

@@ -122,24 +122,24 @@ By default, the WHERE clause renderer assumes that the rendered WHERE clause wil
122122
@Select({
123123
"select id, animal_name, brain_weight, body_weight",
124124
"from AnimalData",
125-
"${whereSupport.whereClause}",
125+
"${whereClauseProvider.whereClause}",
126126
"order by id",
127127
"OFFSET #{offset,jdbcType=INTEGER} LIMIT #{limit,jdbcType=INTEGER}"
128128
})
129129
@ResultMap("AnimalDataResult")
130-
List<AnimalData> selectByExampleWithLimitAndOffset(@Param("whereSupport") WhereClauseAndParameters whereClause,
130+
List<AnimalData> selectByExampleWithLimitAndOffset(@Param("whereClauseProvider") WhereClauseProvider whereClause,
131131
@Param("limit") int limit, @Param("offset") int offset);
132132
```
133133

134134
In this mapper method there are three parameters. So in this case it will be necessary to tell the WHERE rendered what parameter name to use the for rendered where clause. That code looks like this:
135135

136136
```java
137-
WhereClauseAndParameters whereClause = where(id, isLessThan(60))
137+
WhereClauseProvider whereClause = where(id, isLessThan(60))
138138
.build()
139-
.render(RenderingStrategy.MYBATIS3, "whereSupport");
139+
.render(RenderingStrategy.MYBATIS3, "whereClauseProvider");
140140

141141
List<AnimalData> animals = mapper.selectByExampleWithLimitAndOffset(whereClause, 5, 15);
142142
```
143-
Notice that the string `whereSupport` is used both as the parameter name in the mapper `@Param` annotation and the parameter name in the `render` method.
143+
Notice that the string `whereClauseProvider` is used both as the parameter name in the mapper `@Param` annotation and the parameter name in the `render` method.
144144

145145
The render method also has an override that accepts a TableAliasCalculator and a parameter name.

src/test/java/examples/animal/data/AnimalDataMapper.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,22 +86,22 @@ public interface AnimalDataMapper {
8686
@Select({
8787
"select id, animal_name, brain_weight, body_weight",
8888
"from AnimalData",
89-
"${whereSupport.whereClause}",
89+
"${whereClauseProvider.whereClause}",
9090
"order by id",
9191
"OFFSET #{offset,jdbcType=INTEGER} LIMIT #{limit,jdbcType=INTEGER}"
9292
})
9393
@ResultMap("AnimalDataResult")
94-
List<AnimalData> selectByExampleWithLimitAndOffset(@Param("whereSupport") WhereClauseProvider whereClause,
94+
List<AnimalData> selectByExampleWithLimitAndOffset(@Param("whereClauseProvider") WhereClauseProvider whereClause,
9595
@Param("limit") int limit, @Param("offset") int offset);
9696

9797
@Select({
9898
"select b.id, b.animal_name, b.brain_weight, b.body_weight",
9999
"from AnimalData b",
100-
"${whereSupport.whereClause}",
100+
"${whereClauseProvider.whereClause}",
101101
"order by id",
102102
"OFFSET #{offset,jdbcType=INTEGER} LIMIT #{limit,jdbcType=INTEGER}"
103103
})
104104
@ResultMap("AnimalDataResult")
105-
List<AnimalData> selectByExampleWithAliasLimitAndOffset(@Param("whereSupport") WhereClauseProvider whereClause,
105+
List<AnimalData> selectByExampleWithAliasLimitAndOffset(@Param("whereClauseProvider") WhereClauseProvider whereClause,
106106
@Param("limit") int limit, @Param("offset") int offset);
107107
}

src/test/java/examples/animal/data/AnimalDataTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public void testSelectRowsNotBetweenWithStandaloneWhereClauseLimitAndOffset() {
219219

220220
WhereClauseProvider whereClause = where(id, isLessThan(60))
221221
.build()
222-
.render(RenderingStrategy.MYBATIS3, "whereSupport");
222+
.render(RenderingStrategy.MYBATIS3, "whereClauseProvider");
223223

224224
List<AnimalData> animals = mapper.selectByExampleWithLimitAndOffset(whereClause, 5, 15);
225225
assertThat(animals.size()).isEqualTo(5);
@@ -238,7 +238,7 @@ public void testSelectRowsNotBetweenWithStandaloneWhereClauseAliasLimitAndOffset
238238

239239
WhereClauseProvider whereClause = where(id, isLessThan(60))
240240
.build()
241-
.render(RenderingStrategy.MYBATIS3, TableAliasCalculator.of(animalData, "b"), "whereSupport");
241+
.render(RenderingStrategy.MYBATIS3, TableAliasCalculator.of(animalData, "b"), "whereClauseProvider");
242242

243243
List<AnimalData> animals = mapper.selectByExampleWithAliasLimitAndOffset(whereClause, 3, 24);
244244
assertThat(animals.size()).isEqualTo(3);

0 commit comments

Comments
 (0)