File tree Expand file tree Collapse file tree 5 files changed +33
-4
lines changed
main/java/org/mybatis/dynamic/sql/util/mybatis3
test/java/examples/simple Expand file tree Collapse file tree 5 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ language: java
2
2
3
3
jdk :
4
4
- openjdk11
5
- - oraclejdk8
5
+ - openjdk8
6
6
7
7
after_success :
8
8
- chmod -R 777 ./travis/after_success.sh
Original file line number Diff line number Diff line change 18
18
import java .util .List ;
19
19
import java .util .function .Function ;
20
20
21
+ import org .mybatis .dynamic .sql .SortSpecification ;
21
22
import org .mybatis .dynamic .sql .select .MyBatis3SelectModelAdapter ;
22
23
import org .mybatis .dynamic .sql .select .QueryExpressionDSL ;
23
24
import org .mybatis .dynamic .sql .util .Buildable ;
@@ -86,4 +87,16 @@ public interface MyBatis3SelectByExampleHelper<T> extends
86
87
static <T > MyBatis3SelectByExampleHelper <T > allRows () {
87
88
return h -> h ;
88
89
}
90
+
91
+ /**
92
+ * Returns a helper that can be used to select every row in a table with a specified sort order.
93
+ *
94
+ * @param <T> the type of row returned
95
+ * @param columns sort columns
96
+ *
97
+ * @return the helper that will select every row in a table in the specified order
98
+ */
99
+ static <T > MyBatis3SelectByExampleHelper <T > allRowsOrderdBy (SortSpecification ...columns ) {
100
+ return h -> h .orderBy (columns );
101
+ }
89
102
}
Original file line number Diff line number Diff line change 21
21
import org .mybatis .dynamic .sql .update .UpdateDSL ;
22
22
23
23
/**
24
- * Represents a function that can be used to create an "UpdateByExample" method in the style
24
+ * Represents a function that can be used to set values in an "UpdateByExample" method in the style
25
25
* of MyBatis Generator. When using this function, you can create a method that will map record fields to
26
26
* tables columns to be updated in a common mapper, and then allow a user to set a where clause as needed.
27
27
*
Original file line number Diff line number Diff line change @@ -88,6 +88,22 @@ public void testSelectAll() {
88
88
List <SimpleTableRecord > rows = mapper .selectByExample (MyBatis3SelectByExampleHelper .allRows ());
89
89
90
90
assertThat (rows .size ()).isEqualTo (6 );
91
+ assertThat (rows .get (0 ).getId ()).isEqualTo (1 );
92
+ assertThat (rows .get (5 ).getId ()).isEqualTo (6 );
93
+ }
94
+ }
95
+
96
+ @ Test
97
+ public void testSelectAllOrdered () {
98
+ try (SqlSession session = sqlSessionFactory .openSession ()) {
99
+ SimpleTableAnnotatedMapperNewStyle mapper = session .getMapper (SimpleTableAnnotatedMapperNewStyle .class );
100
+
101
+ List <SimpleTableRecord > rows = mapper
102
+ .selectByExample (MyBatis3SelectByExampleHelper .allRowsOrderdBy (lastName .descending (), firstName .descending ()));
103
+
104
+ assertThat (rows .size ()).isEqualTo (6 );
105
+ assertThat (rows .get (0 ).getId ()).isEqualTo (5 );
106
+ assertThat (rows .get (5 ).getId ()).isEqualTo (1 );
91
107
}
92
108
}
93
109
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
#
3
- # Copyright 2016-2018 the original author or authors.
3
+ # Copyright 2016-2019 the original author or authors.
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
6
# you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ echo "Current commit detected: ${commit_message}"
32
32
# a. Use -q option to only display Maven errors and warnings.
33
33
# b. Use --settings to force the usage of our "settings.xml" file.
34
34
35
- if [ $TRAVIS_JDK_VERSION == " oraclejdk8 " ] && [ $TRAVIS_REPO_SLUG == " mybatis/mybatis-dynamic-sql" ]; then
35
+ if [ $TRAVIS_JDK_VERSION == " openjdk8 " ] && [ $TRAVIS_REPO_SLUG == " mybatis/mybatis-dynamic-sql" ]; then
36
36
37
37
./mvnw clean test jacoco:report coveralls:report -q
38
38
echo -e " Successfully ran coveralls under Travis job ${TRAVIS_JOB_NUMBER} "
You can’t perform that action at this time.
0 commit comments