19
19
import static org .mybatis .dynamic .sql .SqlBuilder .*;
20
20
21
21
import java .util .List ;
22
+ import java .util .function .Function ;
22
23
23
24
import org .apache .ibatis .annotations .DeleteProvider ;
24
25
import org .apache .ibatis .annotations .InsertProvider ;
28
29
import org .apache .ibatis .annotations .Results ;
29
30
import org .apache .ibatis .annotations .SelectProvider ;
30
31
import org .apache .ibatis .annotations .UpdateProvider ;
32
+ import org .apache .ibatis .session .RowBounds ;
31
33
import org .apache .ibatis .type .JdbcType ;
32
34
import org .mybatis .dynamic .sql .SqlBuilder ;
33
35
import org .mybatis .dynamic .sql .delete .DeleteDSL ;
44
46
import org .mybatis .dynamic .sql .update .render .UpdateStatementProvider ;
45
47
import org .mybatis .dynamic .sql .util .SqlProviderAdapter ;
46
48
49
+ /**
50
+ *
51
+ * Note: this is the canonical mapper and represents the desired output for MyBatis Generator
52
+ *
53
+ */
47
54
@ Mapper
48
55
public interface SimpleTableAnnotatedMapper {
49
56
@@ -64,6 +71,10 @@ public interface SimpleTableAnnotatedMapper {
64
71
})
65
72
List <SimpleTableRecord > selectMany (SelectStatementProvider selectStatement );
66
73
74
+ @ SelectProvider (type =SqlProviderAdapter .class , method ="select" )
75
+ @ ResultMap ("SimpleTableResult" )
76
+ List <SimpleTableRecord > selectManyWithRowbounds (SelectStatementProvider selectStatement , RowBounds rowBounds );
77
+
67
78
@ SelectProvider (type =SqlProviderAdapter .class , method ="select" )
68
79
@ ResultMap ("SimpleTableResult" )
69
80
SimpleTableRecord selectOne (SelectStatementProvider selectStatement );
@@ -74,6 +85,10 @@ public interface SimpleTableAnnotatedMapper {
74
85
@ SelectProvider (type =SqlProviderAdapter .class , method ="select" )
75
86
long count (SelectStatementProvider selectStatement );
76
87
88
+ default Function <SelectStatementProvider , List <SimpleTableRecord >> selectManyWithRowbounds (RowBounds rowBounds ) {
89
+ return selectStatement -> selectManyWithRowbounds (selectStatement , rowBounds );
90
+ }
91
+
77
92
default QueryExpressionDSL <MyBatis3SelectModelAdapter <Long >> countByExample () {
78
93
return SelectDSL .selectWithMapper (this ::count , SqlBuilder .count ())
79
94
.from (simpleTable );
@@ -121,11 +136,21 @@ default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<SimpleTableRecord>>>
121
136
.from (simpleTable );
122
137
}
123
138
139
+ default QueryExpressionDSL <MyBatis3SelectModelAdapter <List <SimpleTableRecord >>> selectByExample (RowBounds rowBounds ) {
140
+ return SelectDSL .selectWithMapper (selectManyWithRowbounds (rowBounds ), id .as ("A_ID" ), firstName , lastName , birthDate , employed , occupation )
141
+ .from (simpleTable );
142
+ }
143
+
124
144
default QueryExpressionDSL <MyBatis3SelectModelAdapter <List <SimpleTableRecord >>> selectDistinctByExample () {
125
145
return SelectDSL .selectDistinctWithMapper (this ::selectMany , id .as ("A_ID" ), firstName , lastName , birthDate , employed , occupation )
126
146
.from (simpleTable );
127
147
}
128
148
149
+ default QueryExpressionDSL <MyBatis3SelectModelAdapter <List <SimpleTableRecord >>> selectDistinctByExample (RowBounds rowBounds ) {
150
+ return SelectDSL .selectDistinctWithMapper (selectManyWithRowbounds (rowBounds ), id .as ("A_ID" ), firstName , lastName , birthDate , employed , occupation )
151
+ .from (simpleTable );
152
+ }
153
+
129
154
default SimpleTableRecord selectByPrimaryKey (Integer id_ ) {
130
155
return SelectDSL .selectWithMapper (this ::selectOne , id .as ("A_ID" ), firstName , lastName , birthDate , employed , occupation )
131
156
.from (simpleTable )
@@ -156,7 +181,6 @@ default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(
156
181
157
182
default int updateByPrimaryKey (SimpleTableRecord record ) {
158
183
return UpdateDSL .updateWithMapper (this ::update , simpleTable )
159
- .set (id ).equalTo (record ::getId )
160
184
.set (firstName ).equalTo (record ::getFirstName )
161
185
.set (lastName ).equalTo (record ::getLastName )
162
186
.set (birthDate ).equalTo (record ::getBirthDate )
@@ -169,7 +193,6 @@ default int updateByPrimaryKey(SimpleTableRecord record) {
169
193
170
194
default int updateByPrimaryKeySelective (SimpleTableRecord record ) {
171
195
return UpdateDSL .updateWithMapper (this ::update , simpleTable )
172
- .set (id ).equalToWhenPresent (record ::getId )
173
196
.set (firstName ).equalToWhenPresent (record ::getFirstName )
174
197
.set (lastName ).equalToWhenPresent (record ::getLastName )
175
198
.set (birthDate ).equalToWhenPresent (record ::getBirthDate )
0 commit comments