Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: java

jdk:
- openjdk11
- oraclejdk8
- openjdk8

after_success:
- chmod -R 777 ./travis/after_success.sh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.List;
import java.util.function.Function;

import org.mybatis.dynamic.sql.SortSpecification;
import org.mybatis.dynamic.sql.select.MyBatis3SelectModelAdapter;
import org.mybatis.dynamic.sql.select.QueryExpressionDSL;
import org.mybatis.dynamic.sql.util.Buildable;
Expand Down Expand Up @@ -86,4 +87,16 @@ public interface MyBatis3SelectByExampleHelper<T> extends
static <T> MyBatis3SelectByExampleHelper<T> allRows() {
return h -> h;
}

/**
* Returns a helper that can be used to select every row in a table with a specified sort order.
*
* @param <T> the type of row returned
* @param columns sort columns
*
* @return the helper that will select every row in a table in the specified order
*/
static <T> MyBatis3SelectByExampleHelper<T> allRowsOrderdBy(SortSpecification...columns) {
return h -> h.orderBy(columns);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.mybatis.dynamic.sql.update.UpdateDSL;

/**
* Represents a function that can be used to create an "UpdateByExample" method in the style
* Represents a function that can be used to set values in an "UpdateByExample" method in the style
* of MyBatis Generator. When using this function, you can create a method that will map record fields to
* tables columns to be updated in a common mapper, and then allow a user to set a where clause as needed.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ public void testSelectAll() {
List<SimpleTableRecord> rows = mapper.selectByExample(MyBatis3SelectByExampleHelper.allRows());

assertThat(rows.size()).isEqualTo(6);
assertThat(rows.get(0).getId()).isEqualTo(1);
assertThat(rows.get(5).getId()).isEqualTo(6);
}
}

@Test
public void testSelectAllOrdered() {
try (SqlSession session = sqlSessionFactory.openSession()) {
SimpleTableAnnotatedMapperNewStyle mapper = session.getMapper(SimpleTableAnnotatedMapperNewStyle.class);

List<SimpleTableRecord> rows = mapper
.selectByExample(MyBatis3SelectByExampleHelper.allRowsOrderdBy(lastName.descending(), firstName.descending()));

assertThat(rows.size()).isEqualTo(6);
assertThat(rows.get(0).getId()).isEqualTo(5);
assertThat(rows.get(5).getId()).isEqualTo(1);
}
}

Expand Down
4 changes: 2 additions & 2 deletions travis/after_success.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright 2016-2018 the original author or authors.
# Copyright 2016-2019 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,7 +32,7 @@ echo "Current commit detected: ${commit_message}"
# a. Use -q option to only display Maven errors and warnings.
# b. Use --settings to force the usage of our "settings.xml" file.

if [ $TRAVIS_JDK_VERSION == "oraclejdk8" ] && [ $TRAVIS_REPO_SLUG == "mybatis/mybatis-dynamic-sql" ]; then
if [ $TRAVIS_JDK_VERSION == "openjdk8" ] && [ $TRAVIS_REPO_SLUG == "mybatis/mybatis-dynamic-sql" ]; then

./mvnw clean test jacoco:report coveralls:report -q
echo -e "Successfully ran coveralls under Travis job ${TRAVIS_JOB_NUMBER}"
Expand Down