Skip to content

Commit

Permalink
Merge pull request #824 from jeffgbutler/java-11-update
Browse files Browse the repository at this point in the history
Update to Java 17
  • Loading branch information
jeffgbutler authored Aug 5, 2024
2 parents 545e4be + 73f5e8f commit bb60c74
Show file tree
Hide file tree
Showing 18 changed files with 79 additions and 112 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This log will detail notable changes to MyBatis Dynamic SQL. Full details are available on the GitHub milestone pages.

## Release 2.0.0 - Unreleased

The library now requires Java 17.

## Release 1.5.2 - June 3, 2024

This is a small maintenance release with the following changes:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ The library test cases provide several complete examples of using the library in

## Requirements

The library has no dependencies. Java 8 or higher is required.
The library has no dependencies. Version 2.x requires Java 17. Version 1.8 requires Java 8.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<groupId>org.mybatis.dynamic-sql</groupId>
<artifactId>mybatis-dynamic-sql</artifactId>
<version>1.6.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>

<name>MyBatis Dynamic SQL</name>
<description>MyBatis framework for generating dynamic SQL</description>
Expand Down Expand Up @@ -57,8 +57,8 @@

<properties>
<java.version>17</java.version>
<java.release.version>8</java.release.version>
<junit.jupiter.version>5.10.3</junit.jupiter.version>
<java.release.version>17</java.release.version>
<junit.jupiter.version>5.10.2</junit.jupiter.version>
<spring.batch.version>5.1.2</spring.batch.version>

<checkstyle.config>checkstyle-override.xml</checkstyle.config>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ private GeneralInsertRenderer(Builder builder) {
public GeneralInsertStatementProvider render() {
FieldAndValueCollector collector = model.columnMappings()
.map(m -> m.accept(visitor))
.filter(Optional::isPresent)
.map(Optional::get)
.flatMap(Optional::stream)
.collect(FieldAndValueCollector.collect());

Validator.assertFalse(collector.isEmpty(), "ERROR.9"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ private InsertRenderer(Builder<T> builder) {
public InsertStatementProvider<T> render() {
FieldAndValueCollector collector = model.columnMappings()
.map(m -> m.accept(visitor))
.filter(Optional::isPresent)
.map(Optional::get)
.flatMap(Optional::stream)
.collect(FieldAndValueCollector.collect());

Validator.assertFalse(collector.isEmpty(), "ERROR.10"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ private FragmentAndParameters calculateSetPhrase() {
"ERROR.18"); //$NON-NLS-1$

FragmentCollector fragmentCollector = fragmentsAndParameters.stream()
.filter(Optional::isPresent)
.map(Optional::get)
.flatMap(Optional::stream)
.collect(FragmentCollector.collect());

return toSetPhrase(fragmentCollector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ private FragmentAndParameters renderExists(ExistsCriterion criterion) {

private List<RenderedCriterion> renderSubCriteria(List<AndOrCriteriaGroup> subCriteria) {
return subCriteria.stream().map(this::renderAndOrCriteriaGroup)
.filter(Optional::isPresent)
.map(Optional::get)
.flatMap(Optional::stream)
.collect(Collectors.toList());
}

Expand Down
4 changes: 2 additions & 2 deletions src/site/markdown/docs/conditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ any null or blank string, and you want to trim all strings. This can be accompli
.where(animalName, isIn(" Mouse", " ", null, "", "Musk shrew ")
.filter(Objects::nonNull)
.map(String::trim)
.filter(st -> !st.isEmpty()))
.filter(not(String::isEmpty)))
.orderBy(id)
.build()
.render(RenderingStrategies.MYBATIS3);
Expand All @@ -284,7 +284,7 @@ public class MyInCondition {
return SqlBuilder.isIn(values)
.filter(Objects::nonNull)
.map(String::trim)
.filter(st -> !st.isEmpty());
.filter(not(String::isEmpty));
}
}
```
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/examples/animal/data/MyInCondition.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package examples.animal.data;

import static java.util.function.Predicate.not;

import java.util.Objects;

import org.mybatis.dynamic.sql.SqlBuilder;
Expand All @@ -25,6 +27,6 @@ public static IsIn<String> isIn(String...values) {
return SqlBuilder.isIn(values)
.filter(Objects::nonNull)
.map((String::trim))
.filter(st -> !st.isEmpty());
.filter(not(String::isEmpty));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static examples.animal.data.AnimalDataDynamicSqlSupport.bodyWeight;
import static examples.animal.data.AnimalDataDynamicSqlSupport.brainWeight;
import static examples.animal.data.AnimalDataDynamicSqlSupport.id;
import static java.util.function.Predicate.not;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.mybatis.dynamic.sql.SqlBuilder.*;
Expand Down Expand Up @@ -484,7 +485,7 @@ void testValueStreamTransformer() {
.where(animalName, isIn(" Mouse", " ", null, "", "Musk shrew ")
.filter(Objects::nonNull)
.map(String::trim)
.filter(st -> !st.isEmpty()))
.filter(not(String::isEmpty)))
.orderBy(id)
.build()
.render(RenderingStrategies.MYBATIS3);
Expand Down
7 changes: 1 addition & 6 deletions src/test/java/examples/emptywhere/EmptyWhereTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ static List<Variation> baseVariations() {

Variation v4 = new Variation(null, null, "");

List<Variation> answer = new ArrayList<>();
answer.add(v1);
answer.add(v2);
answer.add(v3);
answer.add(v4);
return answer;
return List.of(v1, v2, v3, v4);
}

static Stream<Variation> whereVariations() {
Expand Down
10 changes: 2 additions & 8 deletions src/test/java/examples/simple/MyBatisMapToRowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ void testInsertMultiple() {
try (SqlSession session = sqlSessionFactory.openSession()) {
CompoundKeyMapper mapper = session.getMapper(CompoundKeyMapper.class);

List<Integer> integers = new ArrayList<>();
integers.add(1);
integers.add(2);
integers.add(3);
List<Integer> integers = List.of(1, 2, 3);

MultiRowInsertStatementProvider<Integer> insertStatement = insertMultiple(integers)
.into(compoundKey)
Expand Down Expand Up @@ -142,10 +139,7 @@ void testInsertBatch() {
try (SqlSession session = sqlSessionFactory.openSession(ExecutorType.BATCH)) {
CompoundKeyMapper mapper = session.getMapper(CompoundKeyMapper.class);

List<Integer> integers = new ArrayList<>();
integers.add(1);
integers.add(2);
integers.add(3);
List<Integer> integers = List.of(1, 2, 3);

BatchInsert<Integer> insertStatement = insertBatch(integers)
.into(compoundKey)
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/examples/simple/PersonMapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ void testFirstNameIn() {

@Test
void testOrderByCollection() {
Collection<SortSpecification> orderByColumns = new ArrayList<>();
orderByColumns.add(firstName);
Collection<SortSpecification> orderByColumns = List.of(firstName);

try (SqlSession session = sqlSessionFactory.openSession()) {
PersonMapper mapper = session.getMapper(PersonMapper.class);
Expand Down
10 changes: 2 additions & 8 deletions src/test/java/examples/spring/SpringMapToRowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ void testInsertOne() {

@Test
void testInsertMultiple() {
List<Integer> integers = new ArrayList<>();
integers.add(1);
integers.add(2);
integers.add(3);
List<Integer> integers = List.of(1, 2, 3);

MultiRowInsertStatementProvider<Integer> insertStatement = insertMultiple(integers)
.into(compoundKey)
Expand All @@ -102,10 +99,7 @@ void testInsertMultiple() {

@Test
void testInsertBatch() {
List<Integer> integers = new ArrayList<>();
integers.add(1);
integers.add(2);
integers.add(3);
List<Integer> integers = List.of(1, 2, 3);

BatchInsert<Integer> insertStatement = insertBatch(integers)
.into(compoundKey)
Expand Down
63 changes: 31 additions & 32 deletions src/test/java/issues/gh430/NoInitialConditionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static org.mybatis.dynamic.sql.SqlBuilder.*;
import static org.mybatis.dynamic.sql.subselect.FooDynamicSqlSupport.*;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

Expand All @@ -32,7 +32,7 @@ class NoInitialConditionTest {

@Test
void testNoInitialConditionEmptyList() {
List<AndOrCriteriaGroup> criteria = new ArrayList<>();
List<AndOrCriteriaGroup> criteria = Collections.emptyList();

SelectStatementProvider selectStatement = buildSelectStatement(criteria);

Expand All @@ -43,8 +43,7 @@ void testNoInitialConditionEmptyList() {

@Test
void testNoInitialConditionSingleSub() {
List<AndOrCriteriaGroup> criteria = new ArrayList<>();
criteria.add(or(column2, isEqualTo(3)));
List<AndOrCriteriaGroup> criteria = List.of(or(column2, isEqualTo(3)));

SelectStatementProvider selectStatement = buildSelectStatement(criteria);

Expand All @@ -56,10 +55,10 @@ void testNoInitialConditionSingleSub() {

@Test
void testNoInitialConditionMultipleSubs() {
List<AndOrCriteriaGroup> criteria = new ArrayList<>();
criteria.add(or(column2, isEqualTo(3)));
criteria.add(or(column2, isEqualTo(4)));
criteria.add(or(column2, isEqualTo(5)));
List<AndOrCriteriaGroup> criteria = List.of(
or(column2, isEqualTo(3)),
or(column2, isEqualTo(4)),
or(column2, isEqualTo(5)));

SelectStatementProvider selectStatement = buildSelectStatement(criteria);

Expand All @@ -71,10 +70,10 @@ void testNoInitialConditionMultipleSubs() {

@Test
void testNoInitialConditionWhereMultipleSubs() {
List<AndOrCriteriaGroup> criteria = new ArrayList<>();
criteria.add(or(column2, isEqualTo(3)));
criteria.add(or(column2, isEqualTo(4)));
criteria.add(or(column2, isEqualTo(5)));
List<AndOrCriteriaGroup> criteria = List.of(
or(column2, isEqualTo(3)),
or(column2, isEqualTo(4)),
or(column2, isEqualTo(5)));

SelectStatementProvider selectStatement = select(column1, column2)
.from(foo)
Expand All @@ -90,10 +89,10 @@ void testNoInitialConditionWhereMultipleSubs() {

@Test
void testNoInitialConditionWhereNotMultipleSubs() {
List<AndOrCriteriaGroup> criteria = new ArrayList<>();
criteria.add(or(column2, isEqualTo(3)));
criteria.add(or(column2, isEqualTo(4)));
criteria.add(or(column2, isEqualTo(5)));
List<AndOrCriteriaGroup> criteria = List.of(
or(column2, isEqualTo(3)),
or(column2, isEqualTo(4)),
or(column2, isEqualTo(5)));

SelectStatementProvider selectStatement = select(column1, column2)
.from(foo)
Expand All @@ -110,10 +109,10 @@ void testNoInitialConditionWhereNotMultipleSubs() {

@Test
void testNoInitialConditionWhereGroupMultipleSubs() {
List<AndOrCriteriaGroup> criteria = new ArrayList<>();
criteria.add(or(column2, isEqualTo(3)));
criteria.add(or(column2, isEqualTo(4)));
criteria.add(or(column2, isEqualTo(5)));
List<AndOrCriteriaGroup> criteria = List.of(
or(column2, isEqualTo(3)),
or(column2, isEqualTo(4)),
or(column2, isEqualTo(5)));

SelectStatementProvider selectStatement = select(column1, column2)
.from(foo)
Expand All @@ -130,10 +129,10 @@ void testNoInitialConditionWhereGroupMultipleSubs() {

@Test
void testNoInitialConditionWhereCCAndMultipleSubs() {
List<AndOrCriteriaGroup> criteria = new ArrayList<>();
criteria.add(or(column2, isEqualTo(3)));
criteria.add(or(column2, isEqualTo(4)));
criteria.add(or(column2, isEqualTo(5)));
List<AndOrCriteriaGroup> criteria = List.of(
or(column2, isEqualTo(3)),
or(column2, isEqualTo(4)),
or(column2, isEqualTo(5)));

SelectStatementProvider selectStatement = select(column1, column2)
.from(foo)
Expand All @@ -149,10 +148,10 @@ void testNoInitialConditionWhereCCAndMultipleSubs() {

@Test
void testNoInitialConditionWhereCCOrMultipleSubs() {
List<AndOrCriteriaGroup> criteria = new ArrayList<>();
criteria.add(or(column2, isEqualTo(3)));
criteria.add(or(column2, isEqualTo(4)));
criteria.add(or(column2, isEqualTo(5)));
List<AndOrCriteriaGroup> criteria = List.of(
or(column2, isEqualTo(3)),
or(column2, isEqualTo(4)),
or(column2, isEqualTo(5)));

SelectStatementProvider selectStatement = select(column1, column2)
.from(foo)
Expand All @@ -168,10 +167,10 @@ void testNoInitialConditionWhereCCOrMultipleSubs() {

@Test
void testNoInitialConditionWhereOrMultipleSubs() {
List<AndOrCriteriaGroup> criteria = new ArrayList<>();
criteria.add(or(column2, isEqualTo(3)));
criteria.add(or(column2, isEqualTo(4)));
criteria.add(or(column2, isEqualTo(5)));
List<AndOrCriteriaGroup> criteria = List.of(
or(column2, isEqualTo(3)),
or(column2, isEqualTo(4)),
or(column2, isEqualTo(5)));

SelectStatementProvider selectStatement = select(column1, column2)
.from(foo)
Expand Down
6 changes: 2 additions & 4 deletions src/test/java/org/mybatis/dynamic/sql/InvalidSQLTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ void testInvalidMultipleInsertStatementNoRecords() {

@Test
void testInvalidMultipleInsertStatementNoMappings() {
List<TestRow> records = new ArrayList<>();
records.add(new TestRow());
List<TestRow> records = List.of(new TestRow());

MultiRowInsertModel.Builder<TestRow> builder = new MultiRowInsertModel.Builder<TestRow>()
.withRecords(records)
Expand All @@ -137,8 +136,7 @@ void testInvalidBatchInsertStatementNoRecords() {

@Test
void testInvalidBatchInsertStatementNoMappings() {
List<TestRow> records = new ArrayList<>();
records.add(new TestRow());
List<TestRow> records = List.of(new TestRow());

BatchInsertModel.Builder<TestRow> builder = new BatchInsertModel.Builder<TestRow>()
.withRecords(records)
Expand Down
Loading

0 comments on commit bb60c74

Please sign in to comment.