Skip to content

Commit caeaa7d

Browse files
committed
Make the example code look like the code from the generator
1 parent fba4154 commit caeaa7d

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/test/java/examples/simple/SimpleTableAnnotatedMapper.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ public interface SimpleTableAnnotatedMapper {
7676

7777
default QueryExpressionDSL<MyBatis3SelectModelAdapter<Long>>.QueryExpressionAfterFrom countByExample() {
7878
return SelectDSL.selectWithMapper(this::count, SqlBuilder.count())
79-
.from(simpleTable);
79+
.from(simpleTable);
8080
}
8181

8282
default DeleteDSL<MyBatis3DeleteModelAdapter<Integer>> deleteByExample() {
8383
return DeleteDSL.deleteFromWithMapper(this::delete, simpleTable);
8484
}
8585

8686
default int deleteByPrimaryKey(Integer id_) {
87-
return deleteByExample()
88-
.where(id, isEqualTo(id_))
87+
return DeleteDSL.deleteFromWithMapper(this::delete, simpleTable)
88+
.where(id, isEqualTo(id_))
8989
.build()
9090
.execute();
9191
}
@@ -127,11 +127,11 @@ default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<SimpleTableRecord>>>.
127127
}
128128

129129
default SimpleTableRecord selectByPrimaryKey(Integer id_) {
130-
return selectOne(SqlBuilder.select(id.as("A_ID"), firstName, lastName, birthDate, employed, occupation)
130+
return SelectDSL.selectWithMapper(this::selectOne, id.as("A_ID"), firstName, lastName, birthDate, employed, occupation)
131131
.from(simpleTable)
132132
.where(id, isEqualTo(id_))
133133
.build()
134-
.render(RenderingStrategy.MYBATIS3));
134+
.execute();
135135
}
136136

137137
default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExample(SimpleTableRecord record) {
@@ -155,14 +155,26 @@ default UpdateDSL<MyBatis3UpdateModelAdapter<Integer>> updateByExampleSelective(
155155
}
156156

157157
default int updateByPrimaryKey(SimpleTableRecord record) {
158-
return updateByExample(record)
158+
return UpdateDSL.updateWithMapper(this::update, simpleTable)
159+
.set(id).equalTo(record.getId())
160+
.set(firstName).equalTo(record.getFirstName())
161+
.set(lastName).equalTo(record.getLastName())
162+
.set(birthDate).equalTo(record.getBirthDate())
163+
.set(employed).equalTo(record.getEmployed())
164+
.set(occupation).equalTo(record.getOccupation())
159165
.where(id, isEqualTo(record.getId()))
160166
.build()
161167
.execute();
162168
}
163169

164170
default int updateByPrimaryKeySelective(SimpleTableRecord record) {
165-
return updateByExampleSelective(record)
171+
return UpdateDSL.updateWithMapper(this::update, simpleTable)
172+
.set(id).equalToWhenPresent(record.getId())
173+
.set(firstName).equalToWhenPresent(record.getFirstName())
174+
.set(lastName).equalToWhenPresent(record.getLastName())
175+
.set(birthDate).equalToWhenPresent(record.getBirthDate())
176+
.set(employed).equalToWhenPresent(record.getEmployed())
177+
.set(occupation).equalToWhenPresent(record.getOccupation())
166178
.where(id, isEqualTo(record.getId()))
167179
.build()
168180
.execute();

0 commit comments

Comments
 (0)