Skip to content

Commit c554e74

Browse files
authored
Merge pull request #115 from jeffgbutler/master
Miscellaneous Small Fixes
2 parents 2e2d564 + 46703d5 commit c554e74

File tree

12 files changed

+8
-170
lines changed

12 files changed

+8
-170
lines changed

src/main/java/org/mybatis/dynamic/sql/render/RenderingStrategy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
import org.mybatis.dynamic.sql.BindableColumn;
2121

2222
public abstract class RenderingStrategy {
23+
@SuppressWarnings("squid:S2390")
2324
public static final RenderingStrategy MYBATIS3 = new MyBatis3RenderingStrategy();
25+
@SuppressWarnings("squid:S2390")
2426
public static final RenderingStrategy SPRING_NAMED_PARAMETER = new SpringNamedParameterRenderingStrategy();
2527
public static final String DEFAULT_PARAMETER_PREFIX = "parameters"; //$NON-NLS-1$
2628

src/main/java/org/mybatis/dynamic/sql/util/springbatch/SpringBatchPagingReaderSelectModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public SelectStatementProvider render() {
3535
return new LimitAndOffsetDecorator(selectStatement);
3636
}
3737

38-
public class LimitAndOffsetDecorator implements SelectStatementProvider {
38+
public static class LimitAndOffsetDecorator implements SelectStatementProvider {
3939
private Map<String, Object> parameters = new HashMap<>();
4040
private String selectStatement;
4141

src/main/java/org/mybatis/dynamic/sql/where/condition/IsIn.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,6 @@ public IsIn<T> then(UnaryOperator<Stream<T>> valueStreamTransformer) {
5454
return new IsIn<>(values, valueStreamTransformer);
5555
}
5656

57-
/**
58-
* This method allows you to modify the condition's values before they are placed into the parameter map.
59-
* For example, you could filter nulls, or trim strings, etc. This process will run before final rendering of SQL.
60-
* If you filter values out of the stream, then final condition will not reference those values. If you filter all
61-
* values out of the stream, then the condition will not render.
62-
*
63-
* @param valueStreamTransformer a UnaryOperator that will transform the value stream before
64-
* the values are placed in the parameter map
65-
* @return new condition with the specified transformer
66-
*
67-
* @deprecated See {@link IsIn#then(UnaryOperator)}
68-
*/
69-
@Deprecated
70-
public IsIn<T> withValueStreamOperations(UnaryOperator<Stream<T>> valueStreamTransformer) {
71-
return then(valueStreamTransformer);
72-
}
73-
7457
public static <T> IsIn<T> of(Collection<T> values) {
7558
return new IsIn<>(values);
7659
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsInCaseInsensitive.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,6 @@ public IsInCaseInsensitive then(UnaryOperator<Stream<String>> valueStreamTransfo
5353
return new IsInCaseInsensitive(values, valueStreamTransformer);
5454
}
5555

56-
/**
57-
* This method allows you to modify the condition's values before they are placed into the parameter map.
58-
* For example, you could filter nulls, or trim strings, etc. This process will run before final rendering of SQL.
59-
* If you filter values out of the stream, then final condition will not reference those values. If you filter all
60-
* values out of the stream, then the condition will not render.
61-
*
62-
* @param valueStreamTransformer a UnaryOperator that will transform the value stream before
63-
* the values are placed in the parameter map
64-
* @return new condition with the specified transformer
65-
*
66-
* @deprecated See {@link IsInCaseInsensitive#then(UnaryOperator)}
67-
*/
68-
@Deprecated
69-
public IsInCaseInsensitive withValueStreamOperations(UnaryOperator<Stream<String>> valueStreamTransformer) {
70-
return then(valueStreamTransformer);
71-
}
72-
7356
public static IsInCaseInsensitive of(Collection<String> values) {
7457
return new IsInCaseInsensitive(values);
7558
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotIn.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,23 +55,6 @@ public IsNotIn<T> then(UnaryOperator<Stream<T>> valueStreamTransformer) {
5555
return new IsNotIn<>(values, valueStreamTransformer);
5656
}
5757

58-
/**
59-
* This method allows you to modify the condition's values before they are placed into the parameter map.
60-
* For example, you could filter nulls, or trim strings, etc. This process will run before final rendering of SQL.
61-
* If you filter values out of the stream, then final condition will not reference those values. If you filter all
62-
* values out of the stream, then the condition will not render.
63-
*
64-
* @param valueStreamTransformer a UnaryOperator that will transform the value stream before
65-
* the values are placed in the parameter map
66-
* @return new condition with the specified transformer
67-
*
68-
* @deprecated See {@link IsNotIn#then(UnaryOperator)}
69-
*/
70-
@Deprecated
71-
public IsNotIn<T> withValueStreamOperations(UnaryOperator<Stream<T>> valueStreamTransformer) {
72-
return then(valueStreamTransformer);
73-
}
74-
7558
public static <T> IsNotIn<T> of(Collection<T> values) {
7659
return new IsNotIn<>(values);
7760
}

src/main/java/org/mybatis/dynamic/sql/where/condition/IsNotInCaseInsensitive.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,6 @@ public IsNotInCaseInsensitive then(UnaryOperator<Stream<String>> valueStreamTran
5454
return new IsNotInCaseInsensitive(values, valueStreamTransformer);
5555
}
5656

57-
/**
58-
* This method allows you to modify the condition's values before they are placed into the parameter map.
59-
* For example, you could filter nulls, or trim strings, etc. This process will run before final rendering of SQL.
60-
* If you filter values out of the stream, then final condition will not reference those values. If you filter all
61-
* values out of the stream, then the condition will not render.
62-
*
63-
* @param valueStreamTransformer a UnaryOperator that will transform the value stream before
64-
* the values are placed in the parameter map
65-
* @return new condition with the specified transformer
66-
*
67-
* @deprecated See {@link IsNotInCaseInsensitive#then(UnaryOperator)}
68-
*/
69-
@Deprecated
70-
public IsNotInCaseInsensitive withValueStreamOperations(UnaryOperator<Stream<String>> valueStreamTransformer) {
71-
return then(valueStreamTransformer);
72-
}
73-
7457
public static IsNotInCaseInsensitive of(Collection<String> values) {
7558
return new IsNotInCaseInsensitive(values);
7659
}

src/site/markdown/docs/complexQueries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Complex Queries
2-
Enhancements in version 1.1.2 make it easier to code complex queries. The Select DSL is implemented as a set of related objects. As the select statement is built, intermediate objects of various types are returned from the various methods that implement the DSL. The select statement can be completed by calling the `build()` method many of the intermediate objects. Prior to version 1.1.2, it was necessary to call `build()` on the **last** intermediate object. This restriction has been removed and it is now possible to call `build()` on **any** intermedtae object. This, along with several other enhancements, has simplified the coding of complex queries.
2+
Enhancements in version 1.1.2 make it easier to code complex queries. The Select DSL is implemented as a set of related objects. As the select statement is built, intermediate objects of various types are returned from the various methods that implement the DSL. The select statement can be completed by calling the `build()` method many of the intermediate objects. Prior to version 1.1.2, it was necessary to call `build()` on the **last** intermediate object. This restriction has been removed and it is now possible to call `build()` on **any** intermediate object. This, along with several other enhancements, has simplified the coding of complex queries.
33

44
For example, suppose you want to code a complex search on a Person table. The search parameters are id, first name, and last name. The rules are:
55

src/site/markdown/docs/conditions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ For example, you could code a search like this:
8484

8585
In this example, the three conditions will only be rendered if the values passed to them are not null. If all three values are null, then no where clause will be generated.
8686

87-
Each of the conditions accepts a lamba expression that can be used to determine if the condition should render or not. The lambas will all be of standard JDK types (either `java.util.function.BooleanSupplier`, `java.util.function.Predicate`, or `java.util.function.BiPredicate` depending on the type of condition). The following table lists the optional conditions and shows how to use them:
87+
Each of the conditions accepts a lambda expression that can be used to determine if the condition should render or not. The lambdas will all be of standard JDK types (either `java.util.function.BooleanSupplier`, `java.util.function.Predicate`, or `java.util.function.BiPredicate` depending on the type of condition). The following table lists the optional conditions and shows how to use them:
8888

8989
| Condition | Example | Rendering Rules |
9090
|-----------|---------|-----------------|

src/site/markdown/docs/spring.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The SQL statement objects are created in exactly the same way as for MyBatis - o
1313
```
1414

1515
## Executing Select Statements
16-
The Spring Named Parameter JDBC template expects an SQL statement with parameter markers in the Spring format, and a set of matched parameters. MyBatis Dynamic SQL will generate both. The parameters returned from the generated SQL statement can be wrapped in a Spring `MapSqlParameterSource`. Spring also expects you to provide a row mapper for creating the returned objects. The followin code shows a complete example:
16+
The Spring Named Parameter JDBC template expects an SQL statement with parameter markers in the Spring format, and a set of matched parameters. MyBatis Dynamic SQL will generate both. The parameters returned from the generated SQL statement can be wrapped in a Spring `MapSqlParameterSource`. Spring also expects you to provide a row mapper for creating the returned objects. The following code shows a complete example:
1717

1818
```java
1919
NamedParameterJdbcTemplate template = getTemplate();

src/site/markdown/docs/update.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ For example:
3636
.set(animalName).equalToNull()
3737
.build()
3838
.render(RenderingStrategy.MYBATIS3);
39-
```
39+
```
4040

4141
## Annotated Mapper for Update Statements
4242

@@ -52,7 +52,6 @@ import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
5252
@UpdateProvider(type=SqlProviderAdapter.class, method="update")
5353
int update(UpdateStatementProvider updateStatement);
5454
...
55-
5655
```
5756

5857
## XML Mapper for Update Statements

src/site/markdown/docs/whereClauses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ In this mapper method there are three parameters. So in this case it will be ne
142142
```
143143
Notice that the string `whereClauseProvider` is used both as the parameter name in the mapper `@Param` annotation and the parameter name in the `render` method.
144144

145-
The render method also has an override that accepts a TableAliasCalculator and a parameter name.
145+
The render method also has an override that accepts a TableAliasCalculator and a parameter name.

src/test/java/examples/animal/data/OptionalConditionsWithPredicatesAnimalDataTest.java

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -454,30 +454,6 @@ public void testIsInWhenWithSomeValues() {
454454
}
455455
}
456456

457-
/**
458-
* Delete this test when the deprecated method is deleted
459-
*/
460-
@Test
461-
@Deprecated
462-
public void testIsInWhenWithSomeValuesDeprecated() {
463-
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
464-
AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
465-
SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
466-
.from(animalData)
467-
.where(id, isIn(3, NULL_INTEGER, 5).withValueStreamOperations(s -> s.filter(Objects::nonNull).map(i -> i + 3)))
468-
.orderBy(id)
469-
.build()
470-
.render(RenderingStrategy.MYBATIS3);
471-
List<AnimalData> animals = mapper.selectMany(selectStatement);
472-
assertAll(
473-
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id in (#{parameters.p1,jdbcType=INTEGER},#{parameters.p2,jdbcType=INTEGER}) order by id"),
474-
() -> assertThat(animals.size()).isEqualTo(2),
475-
() -> assertThat(animals.get(0).getId()).isEqualTo(6),
476-
() -> assertThat(animals.get(1).getId()).isEqualTo(8)
477-
);
478-
}
479-
}
480-
481457
@Test
482458
public void testIsInCaseInsensitiveWhenWithValue() {
483459
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
@@ -557,29 +533,6 @@ public void testIsInCaseInsensitiveWhenWithSomeValues() {
557533
}
558534
}
559535

560-
/**
561-
* Delete this test when the deprecated method is deleted
562-
*/
563-
@Test
564-
@Deprecated
565-
public void testIsInCaseInsensitiveWhenWithSomeValuesDeprecated() {
566-
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
567-
AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
568-
SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
569-
.from(animalData)
570-
.where(animalName, isInCaseInsensitive("mouse", null, "musk shrew").withValueStreamOperations(s -> s.filter(Objects::nonNull)))
571-
.orderBy(id)
572-
.build()
573-
.render(RenderingStrategy.MYBATIS3);
574-
List<AnimalData> animals = mapper.selectMany(selectStatement);
575-
assertAll(
576-
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where upper(animal_name) in (#{parameters.p1,jdbcType=VARCHAR},#{parameters.p2,jdbcType=VARCHAR}) order by id"),
577-
() -> assertThat(animals.size()).isEqualTo(2),
578-
() -> assertThat(animals.get(0).getId()).isEqualTo(4)
579-
);
580-
}
581-
}
582-
583536
@Test
584537
public void testIsInCaseInsensitiveWhenWithNoValues() {
585538
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
@@ -640,30 +593,6 @@ public void testIsNotInWhenWithSomeValues() {
640593
}
641594
}
642595

643-
/**
644-
* Delete this test when the deprecated method is deleted
645-
*/
646-
@Test
647-
@Deprecated
648-
public void testIsNotInWhenWithSomeValuesDeprecated() {
649-
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
650-
AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
651-
SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
652-
.from(animalData)
653-
.where(id, isNotIn(3, NULL_INTEGER, 5).withValueStreamOperations(s -> s.filter(Objects::nonNull)))
654-
.and(id, isLessThanOrEqualTo(10))
655-
.orderBy(id)
656-
.build()
657-
.render(RenderingStrategy.MYBATIS3);
658-
List<AnimalData> animals = mapper.selectMany(selectStatement);
659-
assertAll(
660-
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where id not in (#{parameters.p1,jdbcType=INTEGER},#{parameters.p2,jdbcType=INTEGER}) and id <= #{parameters.p3,jdbcType=INTEGER} order by id"),
661-
() -> assertThat(animals.size()).isEqualTo(8),
662-
() -> assertThat(animals.get(0).getId()).isEqualTo(1)
663-
);
664-
}
665-
}
666-
667596
@Test
668597
public void testIsNotInCaseInsensitiveWhenWithValue() {
669598
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
@@ -704,30 +633,6 @@ public void testIsNotInCaseInsensitiveWhenWithSomeValues() {
704633
}
705634
}
706635

707-
/**
708-
* Delete this test when the deprecated method is deleted
709-
*/
710-
@Test
711-
@Deprecated
712-
public void testIsNotInCaseInsensitiveWhenWithSomeValuesDeprecated() {
713-
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
714-
AnimalDataMapper mapper = sqlSession.getMapper(AnimalDataMapper.class);
715-
SelectStatementProvider selectStatement = select(id, animalName, bodyWeight, brainWeight)
716-
.from(animalData)
717-
.where(animalName, isNotInCaseInsensitive("mouse", null, "musk shrew").withValueStreamOperations(s -> s.filter(Objects::nonNull)))
718-
.and(id, isLessThanOrEqualTo(10))
719-
.orderBy(id)
720-
.build()
721-
.render(RenderingStrategy.MYBATIS3);
722-
List<AnimalData> animals = mapper.selectMany(selectStatement);
723-
assertAll(
724-
() -> assertThat(selectStatement.getSelectStatement()).isEqualTo("select id, animal_name, body_weight, brain_weight from AnimalData where upper(animal_name) not in (#{parameters.p1,jdbcType=VARCHAR},#{parameters.p2,jdbcType=VARCHAR}) and id <= #{parameters.p3,jdbcType=INTEGER} order by id"),
725-
() -> assertThat(animals.size()).isEqualTo(8),
726-
() -> assertThat(animals.get(0).getId()).isEqualTo(1)
727-
);
728-
}
729-
}
730-
731636
@Test
732637
public void testIsNotInCaseInsensitiveWhenWithNoValues() {
733638
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {

0 commit comments

Comments
 (0)