|
25 | 25 | import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
|
26 | 26 | import org.junit.jupiter.api.BeforeEach;
|
27 | 27 | import org.junit.jupiter.api.Test;
|
| 28 | +import org.mybatis.dynamic.sql.SortSpecification; |
28 | 29 | import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
|
29 | 30 | import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
|
30 | 31 | import org.mybatis.dynamic.sql.insert.render.GeneralInsertStatementProvider;
|
|
38 | 39 | import java.sql.Connection;
|
39 | 40 | import java.sql.DriverManager;
|
40 | 41 | import java.util.ArrayList;
|
| 42 | +import java.util.Collection; |
41 | 43 | import java.util.Date;
|
42 | 44 | import java.util.List;
|
43 | 45 | import java.util.Objects;
|
@@ -251,6 +253,25 @@ void testFirstNameIn() {
|
251 | 253 | }
|
252 | 254 | }
|
253 | 255 |
|
| 256 | + @Test |
| 257 | + void testOrderByCollection() { |
| 258 | + Collection<SortSpecification> orderByColumns = new ArrayList<>(); |
| 259 | + orderByColumns.add(firstName); |
| 260 | + |
| 261 | + try (SqlSession session = sqlSessionFactory.openSession()) { |
| 262 | + PersonMapper mapper = session.getMapper(PersonMapper.class); |
| 263 | + |
| 264 | + List<PersonRecord> rows = mapper.select(c -> c |
| 265 | + .where(firstName, isIn("Fred", "Barney")) |
| 266 | + .orderBy(orderByColumns) |
| 267 | + ); |
| 268 | + |
| 269 | + assertThat(rows).hasSize(2); |
| 270 | + assertThat(rows.get(0).getLastName().getName()).isEqualTo("Flintstone"); |
| 271 | + assertThat(rows.get(1).getLastName().getName()).isEqualTo("Rubble"); |
| 272 | + } |
| 273 | + } |
| 274 | + |
254 | 275 | @Test
|
255 | 276 | void testDelete() {
|
256 | 277 | try (SqlSession session = sqlSessionFactory.openSession()) {
|
|
0 commit comments