1919import static org .mybatis .dynamic .sql .SqlBuilder .*;
2020
2121import java .util .List ;
22+ import java .util .function .Function ;
2223
2324import org .apache .ibatis .annotations .DeleteProvider ;
2425import org .apache .ibatis .annotations .InsertProvider ;
2829import org .apache .ibatis .annotations .Results ;
2930import org .apache .ibatis .annotations .SelectProvider ;
3031import org .apache .ibatis .annotations .UpdateProvider ;
32+ import org .apache .ibatis .session .RowBounds ;
3133import org .apache .ibatis .type .JdbcType ;
3234import org .mybatis .dynamic .sql .SqlBuilder ;
3335import org .mybatis .dynamic .sql .delete .DeleteDSL ;
4446import org .mybatis .dynamic .sql .update .render .UpdateStatementProvider ;
4547import org .mybatis .dynamic .sql .util .SqlProviderAdapter ;
4648
49+ /**
50+ *
51+ * Note: this is the canonical mapper and represents the desired output for MyBatis Generator
52+ *
53+ */
4754@ Mapper
4855public interface SimpleTableAnnotatedMapper {
4956
@@ -64,6 +71,10 @@ public interface SimpleTableAnnotatedMapper {
6471 })
6572 List <SimpleTableRecord > selectMany (SelectStatementProvider selectStatement );
6673
74+ @ SelectProvider (type =SqlProviderAdapter .class , method ="select" )
75+ @ ResultMap ("SimpleTableResult" )
76+ List <SimpleTableRecord > selectManyWithRowbounds (SelectStatementProvider selectStatement , RowBounds rowBounds );
77+
6778 @ SelectProvider (type =SqlProviderAdapter .class , method ="select" )
6879 @ ResultMap ("SimpleTableResult" )
6980 SimpleTableRecord selectOne (SelectStatementProvider selectStatement );
@@ -74,6 +85,10 @@ public interface SimpleTableAnnotatedMapper {
7485 @ SelectProvider (type =SqlProviderAdapter .class , method ="select" )
7586 long count (SelectStatementProvider selectStatement );
7687
88+ default Function <SelectStatementProvider , List <SimpleTableRecord >> selectManyWithRowbounds (RowBounds rowBounds ) {
89+ return selectStatement -> selectManyWithRowbounds (selectStatement , rowBounds );
90+ }
91+
7792 default QueryExpressionDSL <MyBatis3SelectModelAdapter <Long >> countByExample () {
7893 return SelectDSL .selectWithMapper (this ::count , SqlBuilder .count ())
7994 .from (simpleTable );
@@ -121,11 +136,21 @@ default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<SimpleTableRecord>>>
121136 .from (simpleTable );
122137 }
123138
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+
124144 default QueryExpressionDSL <MyBatis3SelectModelAdapter <List <SimpleTableRecord >>> selectDistinctByExample () {
125145 return SelectDSL .selectDistinctWithMapper (this ::selectMany , id .as ("A_ID" ), firstName , lastName , birthDate , employed , occupation )
126146 .from (simpleTable );
127147 }
128148
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+
129154 default SimpleTableRecord selectByPrimaryKey (Integer id_ ) {
130155 return SelectDSL .selectWithMapper (this ::selectOne , id .as ("A_ID" ), firstName , lastName , birthDate , employed , occupation )
131156 .from (simpleTable )
@@ -156,7 +181,6 @@ default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(
156181
157182 default int updateByPrimaryKey (SimpleTableRecord record ) {
158183 return UpdateDSL .updateWithMapper (this ::update , simpleTable )
159- .set (id ).equalTo (record ::getId )
160184 .set (firstName ).equalTo (record ::getFirstName )
161185 .set (lastName ).equalTo (record ::getLastName )
162186 .set (birthDate ).equalTo (record ::getBirthDate )
@@ -169,7 +193,6 @@ default int updateByPrimaryKey(SimpleTableRecord record) {
169193
170194 default int updateByPrimaryKeySelective (SimpleTableRecord record ) {
171195 return UpdateDSL .updateWithMapper (this ::update , simpleTable )
172- .set (id ).equalToWhenPresent (record ::getId )
173196 .set (firstName ).equalToWhenPresent (record ::getFirstName )
174197 .set (lastName ).equalToWhenPresent (record ::getLastName )
175198 .set (birthDate ).equalToWhenPresent (record ::getBirthDate )
0 commit comments