Skip to content

Commit c6f0b4a

Browse files
committed
Docs for stand alone WHERE clauses
1 parent 1f8c78c commit c6f0b4a

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/site/markdown/docs/whereClauses.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# WHERE Clause Support
22

33
This library supports the creation of very flexible WHERE clauses. WHERE clauses can be added to DELETE, SELECT,
4-
and UPDATE statements.
4+
and UPDATE statements. WHERE clauses can also stand alone for use in other hand coded SQL.
55

66
## Simple WHERE Clauses
77

@@ -67,3 +67,27 @@ Most of the conditions also support a subquery. For example:
6767
.build()
6868
.render(RenderingStrategy.MYBATIS3);
6969
```
70+
71+
## Stand Alone Where Clauses
72+
You can use the where clause support on its own if you would rather code your own SQL for the remainder of a statement. There may be several reasons to do this - mainly if the library doesn't support some SQL or MyBatisfeature you want to use. A good example would be paginated queries which are currently not support by the library. If you want to use a standalone where clause, you can code a mapper method that looks like this:
73+
74+
```java
75+
@Select({
76+
"select id, animal_name, brain_weight, body_weight",
77+
"from AnimalData",
78+
"${whereClause}"
79+
})
80+
@ResultMap("AnimalDataResult")
81+
List<AnimalData> selectByExample(WhereClauseAndParameters whereClause);
82+
```
83+
84+
You can build a stand alone where clause and call your mapper like this:
85+
86+
```java
87+
WhereClauseAndParameters whereClause = where(id, isNotBetween(10).and(60))
88+
.build()
89+
.render(RenderingStrategy.MYBATIS3);
90+
91+
List<AnimalData> animals = mapper.selectByExample(whereClause);
92+
```
93+

0 commit comments

Comments
 (0)