Skip to content

Commit fba4154

Browse files
committed
Test coverage
1 parent f911edc commit fba4154

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<SimpleTableRecord>>>.
121121
.from(simpleTable);
122122
}
123123

124+
default QueryExpressionDSL<MyBatis3SelectModelAdapter<List<SimpleTableRecord>>>.QueryExpressionAfterFrom selectDistinctByExample() {
125+
return SelectDSL.selectDistinctWithMapper(this::selectMany, id.as("A_ID"), firstName, lastName, birthDate, employed, occupation)
126+
.from(simpleTable);
127+
}
128+
124129
default SimpleTableRecord selectByPrimaryKey(Integer id_) {
125130
return selectOne(SqlBuilder.select(id.as("A_ID"), firstName, lastName, birthDate, employed, occupation)
126131
.from(simpleTable)

src/test/java/examples/simple/SimpleTableAnnotatedMapperTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ public void testSelectByExample() {
8585
}
8686
}
8787

88+
@Test
89+
public void testSelectDistinctByExample() {
90+
SqlSession session = sqlSessionFactory.openSession();
91+
try {
92+
SimpleTableAnnotatedMapper mapper = session.getMapper(SimpleTableAnnotatedMapper.class);
93+
94+
List<SimpleTableRecord> rows = mapper.selectDistinctByExample()
95+
.where(id, isGreaterThan(1))
96+
.or(occupation, isNull())
97+
.build()
98+
.execute();
99+
100+
assertThat(rows.size()).isEqualTo(5);
101+
} finally {
102+
session.close();
103+
}
104+
}
105+
88106
@Test
89107
public void testSelectByExampleWithTypeHandler() {
90108
SqlSession session = sqlSessionFactory.openSession();

0 commit comments

Comments
 (0)