leftColumn) {
+ RenderedParameterInfo parameterInfo = renderingContext.calculateParameterInfo(leftColumn);
+ return FragmentAndParameters.withFragment(parameterInfo.renderedPlaceHolder())
+ .withParameter(parameterInfo.parameterMapKey(), leftColumn.convertParameterType(value))
+ .build();
+ }
+
/**
- * If not empty, apply the predicate to each value in the list and return a new condition with the filtered values.
- * Else returns an empty condition (this).
+ * Conditions may implement Filterable to add optionality to rendering.
+ *
+ * If a condition is Filterable, then a user may add a filter to the usage of the condition that makes a decision
+ * whether to render the condition at runtime. Conditions that fail the filter will be dropped from the
+ * rendered SQL.
*
- * @param predicate predicate applied to the values, if not empty
+ *
Implementations of Filterable may call
+ * {@link AbstractListValueCondition#filterSupport(Predicate, Function, AbstractListValueCondition, Supplier)} as
+ * a common implementation of the filtering algorithm.
*
- * @return a new condition with filtered values if renderable, otherwise an empty condition
+ * @param the Java type related to the database column type
*/
- public abstract AbstractListValueCondition filter(Predicate super T> predicate);
+ public interface Filterable {
+ /**
+ * If renderable and the value matches the predicate, returns this condition. Else returns a condition
+ * that will not render.
+ *
+ * @param predicate predicate applied to the value, if renderable
+ * @return this condition if renderable and the value matches the predicate, otherwise a condition
+ * that will not render.
+ */
+ AbstractListValueCondition filter(Predicate super @NonNull T> predicate);
+ }
- public abstract String operator();
+ /**
+ * Conditions may implement Mappable to alter condition values or types during rendering.
+ *
+ * If a condition is Mappable, then a user may add a mapper to the usage of the condition that can alter the
+ * values of a condition, or change that datatype.
+ *
+ *
Implementations of Mappable may call
+ * {@link AbstractListValueCondition#mapSupport(Function, Function, Supplier)} as
+ * a common implementation of the mapping algorithm.
+ *
+ * @param the Java type related to the database column type
+ */
+ public interface Mappable {
+ /**
+ * If renderable, apply the mapping to the value and return a new condition with the new value. Else return a
+ * condition that will not render (this).
+ *
+ * @param mapper a mapping function to apply to the value, if renderable
+ * @param type of the new condition
+ * @return a new condition with the result of applying the mapper to the value of this condition,
+ * if renderable, otherwise a condition that will not render.
+ */
+ AbstractListValueCondition map(Function super @NonNull T, ? extends R> mapper);
+ }
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/AbstractNoValueCondition.java b/src/main/java/org/mybatis/dynamic/sql/AbstractNoValueCondition.java
index d6b1c384b..71daa7763 100644
--- a/src/main/java/org/mybatis/dynamic/sql/AbstractNoValueCondition.java
+++ b/src/main/java/org/mybatis/dynamic/sql/AbstractNoValueCondition.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -18,12 +18,10 @@
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;
-public abstract class AbstractNoValueCondition implements VisitableCondition {
+import org.mybatis.dynamic.sql.render.RenderingContext;
+import org.mybatis.dynamic.sql.util.FragmentAndParameters;
- @Override
- public R accept(ConditionVisitor visitor) {
- return visitor.visit(this);
- }
+public abstract class AbstractNoValueCondition implements RenderableCondition {
protected > S filterSupport(BooleanSupplier booleanSupplier,
Supplier emptySupplier, S self) {
@@ -35,4 +33,36 @@ protected > S filterSupport(BooleanSupplie
}
public abstract String operator();
+
+ @Override
+ public FragmentAndParameters renderCondition(RenderingContext renderingContext, BindableColumn leftColumn) {
+ return FragmentAndParameters.fromFragment(operator());
+ }
+
+ /**
+ * Conditions may implement Filterable to add optionality to rendering.
+ *
+ * If a condition is Filterable, then a user may add a filter to the usage of the condition that makes a decision
+ * whether to render the condition at runtime. Conditions that fail the filter will be dropped from the
+ * rendered SQL.
+ *
+ *
Implementations of Filterable may call
+ * {@link AbstractNoValueCondition#filterSupport(BooleanSupplier, Supplier, AbstractNoValueCondition)} as
+ * a common implementation of the filtering algorithm.
+ */
+ public interface Filterable {
+ /**
+ * If renderable and the supplier returns true, returns this condition. Else returns a condition that will not
+ * render.
+ *
+ * @param booleanSupplier
+ * function that specifies whether the condition should render
+ * @param
+ * condition type - not used except for compilation compliance
+ *
+ * @return this condition if renderable and the supplier returns true, otherwise a condition that will not
+ * render.
+ */
+ AbstractNoValueCondition filter(BooleanSupplier booleanSupplier);
+ }
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/AbstractSingleValueCondition.java b/src/main/java/org/mybatis/dynamic/sql/AbstractSingleValueCondition.java
index 1e70adb31..eb56eef39 100644
--- a/src/main/java/org/mybatis/dynamic/sql/AbstractSingleValueCondition.java
+++ b/src/main/java/org/mybatis/dynamic/sql/AbstractSingleValueCondition.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -15,11 +15,18 @@
*/
package org.mybatis.dynamic.sql;
+import static org.mybatis.dynamic.sql.util.StringUtilities.spaceBefore;
+
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
-public abstract class AbstractSingleValueCondition implements VisitableCondition {
+import org.jspecify.annotations.NonNull;
+import org.mybatis.dynamic.sql.render.RenderedParameterInfo;
+import org.mybatis.dynamic.sql.render.RenderingContext;
+import org.mybatis.dynamic.sql.util.FragmentAndParameters;
+
+public abstract class AbstractSingleValueCondition implements RenderableCondition {
protected final T value;
protected AbstractSingleValueCondition(T value) {
@@ -30,11 +37,6 @@ public T value() {
return value;
}
- @Override
- public R accept(ConditionVisitor visitor) {
- return visitor.visit(this);
- }
-
protected > S filterSupport(Predicate super T> predicate,
Supplier emptySupplier, S self) {
if (isEmpty()) {
@@ -53,15 +55,65 @@ protected > S mapSupport(Function
}
}
+ public abstract String operator();
+
+ @Override
+ public FragmentAndParameters renderCondition(RenderingContext renderingContext, BindableColumn leftColumn) {
+ RenderedParameterInfo parameterInfo = renderingContext.calculateParameterInfo(leftColumn);
+ String finalFragment = operator() + spaceBefore(parameterInfo.renderedPlaceHolder());
+
+ return FragmentAndParameters.withFragment(finalFragment)
+ .withParameter(parameterInfo.parameterMapKey(), leftColumn.convertParameterType(value()))
+ .build();
+ }
+
/**
- * If renderable and the value matches the predicate, returns this condition. Else returns a condition
- * that will not render.
+ * Conditions may implement Filterable to add optionality to rendering.
*
- * @param predicate predicate applied to the value, if renderable
- * @return this condition if renderable and the value matches the predicate, otherwise a condition
- * that will not render.
+ * If a condition is Filterable, then a user may add a filter to the usage of the condition that makes a decision
+ * whether to render the condition at runtime. Conditions that fail the filter will be dropped from the
+ * rendered SQL.
+ *
+ *
Implementations of Filterable may call
+ * {@link AbstractSingleValueCondition#filterSupport(Predicate, Supplier, AbstractSingleValueCondition)} as
+ * a common implementation of the filtering algorithm.
+ *
+ * @param the Java type related to the database column type
*/
- public abstract AbstractSingleValueCondition filter(Predicate super T> predicate);
+ public interface Filterable {
+ /**
+ * If renderable and the value matches the predicate, returns this condition. Else returns a condition
+ * that will not render.
+ *
+ * @param predicate predicate applied to the value, if renderable
+ * @return this condition if renderable and the value matches the predicate, otherwise a condition
+ * that will not render.
+ */
+ AbstractSingleValueCondition filter(Predicate super @NonNull T> predicate);
+ }
- public abstract String operator();
+ /**
+ * Conditions may implement Mappable to alter condition values or types during rendering.
+ *
+ * If a condition is Mappable, then a user may add a mapper to the usage of the condition that can alter the
+ * values of a condition, or change that datatype.
+ *
+ *
Implementations of Mappable may call
+ * {@link AbstractSingleValueCondition#mapSupport(Function, Function, Supplier)} as
+ * a common implementation of the mapping algorithm.
+ *
+ * @param the Java type related to the database column type
+ */
+ public interface Mappable {
+ /**
+ * If renderable, apply the mapping to the value and return a new condition with the new value. Else return a
+ * condition that will not render (this).
+ *
+ * @param mapper a mapping function to apply to the value, if renderable
+ * @param type of the new condition
+ * @return a new condition with the result of applying the mapper to the value of this condition,
+ * if renderable, otherwise a condition that will not render.
+ */
+ AbstractSingleValueCondition map(Function super @NonNull T, ? extends R> mapper);
+ }
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/AbstractSubselectCondition.java b/src/main/java/org/mybatis/dynamic/sql/AbstractSubselectCondition.java
index f17e29066..dcfbd4b3c 100644
--- a/src/main/java/org/mybatis/dynamic/sql/AbstractSubselectCondition.java
+++ b/src/main/java/org/mybatis/dynamic/sql/AbstractSubselectCondition.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -15,24 +15,28 @@
*/
package org.mybatis.dynamic.sql;
+import org.mybatis.dynamic.sql.render.RenderingContext;
import org.mybatis.dynamic.sql.select.SelectModel;
+import org.mybatis.dynamic.sql.select.render.SubQueryRenderer;
import org.mybatis.dynamic.sql.util.Buildable;
+import org.mybatis.dynamic.sql.util.FragmentAndParameters;
-public abstract class AbstractSubselectCondition implements VisitableCondition {
+public abstract class AbstractSubselectCondition implements RenderableCondition {
private final SelectModel selectModel;
protected AbstractSubselectCondition(Buildable selectModelBuilder) {
this.selectModel = selectModelBuilder.build();
}
- public SelectModel selectModel() {
- return selectModel;
- }
+ public abstract String operator();
@Override
- public R accept(ConditionVisitor visitor) {
- return visitor.visit(this);
+ public FragmentAndParameters renderCondition(RenderingContext renderingContext, BindableColumn leftColumn) {
+ return SubQueryRenderer.withSelectModel(selectModel)
+ .withRenderingContext(renderingContext)
+ .withPrefix(operator() + " (") //$NON-NLS-1$
+ .withSuffix(")") //$NON-NLS-1$
+ .build()
+ .render();
}
-
- public abstract String operator();
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/AbstractTwoValueCondition.java b/src/main/java/org/mybatis/dynamic/sql/AbstractTwoValueCondition.java
index ee8b3c577..d409ffbb8 100644
--- a/src/main/java/org/mybatis/dynamic/sql/AbstractTwoValueCondition.java
+++ b/src/main/java/org/mybatis/dynamic/sql/AbstractTwoValueCondition.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -15,13 +15,20 @@
*/
package org.mybatis.dynamic.sql;
+import static org.mybatis.dynamic.sql.util.StringUtilities.spaceBefore;
+
import java.util.function.BiFunction;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
-public abstract class AbstractTwoValueCondition implements VisitableCondition {
+import org.jspecify.annotations.NonNull;
+import org.mybatis.dynamic.sql.render.RenderedParameterInfo;
+import org.mybatis.dynamic.sql.render.RenderingContext;
+import org.mybatis.dynamic.sql.util.FragmentAndParameters;
+
+public abstract class AbstractTwoValueCondition implements RenderableCondition {
protected final T value1;
protected final T value2;
@@ -38,11 +45,6 @@ public T value2() {
return value2;
}
- @Override
- public R accept(ConditionVisitor visitor) {
- return visitor.visit(this);
- }
-
protected > S filterSupport(BiPredicate super T, ? super T> predicate,
Supplier emptySupplier, S self) {
if (isEmpty()) {
@@ -66,28 +68,98 @@ protected > S mapSupport(Function su
}
}
+ public abstract String operator1();
+
+ public abstract String operator2();
+
+ @Override
+ public FragmentAndParameters renderCondition(RenderingContext renderingContext, BindableColumn leftColumn) {
+ RenderedParameterInfo parameterInfo1 = renderingContext.calculateParameterInfo(leftColumn);
+ RenderedParameterInfo parameterInfo2 = renderingContext.calculateParameterInfo(leftColumn);
+
+ String finalFragment = operator1()
+ + spaceBefore(parameterInfo1.renderedPlaceHolder())
+ + spaceBefore(operator2())
+ + spaceBefore(parameterInfo2.renderedPlaceHolder());
+
+ return FragmentAndParameters.withFragment(finalFragment)
+ .withParameter(parameterInfo1.parameterMapKey(), leftColumn.convertParameterType(value1()))
+ .withParameter(parameterInfo2.parameterMapKey(), leftColumn.convertParameterType(value2()))
+ .build();
+ }
+
/**
- * If renderable and the values match the predicate, returns this condition. Else returns a condition
- * that will not render.
+ * Conditions may implement Filterable to add optionality to rendering.
+ *
+ * If a condition is Filterable, then a user may add a filter to the usage of the condition that makes a decision
+ * whether to render the condition at runtime. Conditions that fail the filter will be dropped from the
+ * rendered SQL.
*
- * @param predicate predicate applied to the values, if renderable
- * @return this condition if renderable and the values match the predicate, otherwise a condition
- * that will not render.
+ *
Implementations of Filterable may call
+ * {@link AbstractTwoValueCondition#filterSupport(Predicate, Supplier, AbstractTwoValueCondition)}
+ * or {@link AbstractTwoValueCondition#filterSupport(BiPredicate, Supplier, AbstractTwoValueCondition)} as
+ * a common implementation of the filtering algorithm.
+ *
+ * @param the Java type related to the database column type
*/
- public abstract AbstractTwoValueCondition filter(BiPredicate super T, ? super T> predicate);
+ public interface Filterable {
+ /**
+ * If renderable and the values match the predicate, returns this condition. Else returns a condition
+ * that will not render.
+ *
+ * @param predicate predicate applied to the values, if renderable
+ * @return this condition if renderable and the values match the predicate, otherwise a condition
+ * that will not render.
+ */
+ AbstractTwoValueCondition filter(BiPredicate super @NonNull T, ? super @NonNull T> predicate);
+
+ /**
+ * If renderable and both values match the predicate, returns this condition. Else returns a condition
+ * that will not render. This function implements a short-circuiting test. If the
+ * first value does not match the predicate, then the second value will not be tested.
+ *
+ * @param predicate predicate applied to both values, if renderable
+ * @return this condition if renderable and the values match the predicate, otherwise a condition
+ * that will not render.
+ */
+ AbstractTwoValueCondition filter(Predicate super @NonNull T> predicate);
+ }
/**
- * If renderable and both values match the predicate, returns this condition. Else returns a condition
- * that will not render. This function implements a short-circuiting test. If the
- * first value does not match the predicate, then the second value will not be tested.
+ * Conditions may implement Mappable to alter condition values or types during rendering.
*
- * @param predicate predicate applied to both values, if renderable
- * @return this condition if renderable and the values match the predicate, otherwise a condition
- * that will not render.
+ * If a condition is Mappable, then a user may add a mapper to the usage of the condition that can alter the
+ * values of a condition, or change that datatype.
+ *
+ *
Implementations of Mappable may call
+ * {@link AbstractTwoValueCondition#mapSupport(Function, Function, BiFunction, Supplier)} as
+ * a common implementation of the mapping algorithm.
+ *
+ * @param the Java type related to the database column type
*/
- public abstract AbstractTwoValueCondition filter(Predicate super T> predicate);
-
- public abstract String operator1();
+ public interface Mappable {
+ /**
+ * If renderable, apply the mappings to the values and return a new condition with the new values. Else return a
+ * condition that will not render (this).
+ *
+ * @param mapper1 a mapping function to apply to the first value, if renderable
+ * @param mapper2 a mapping function to apply to the second value, if renderable
+ * @param type of the new condition
+ * @return a new condition with the result of applying the mappers to the values of this condition,
+ * if renderable, otherwise a condition that will not render.
+ */
+ AbstractTwoValueCondition map(Function super @NonNull T, ? extends R> mapper1,
+ Function super @NonNull T, ? extends R> mapper2);
- public abstract String operator2();
+ /**
+ * If renderable, apply the mapping to both values and return a new condition with the new values. Else return a
+ * condition that will not render (this).
+ *
+ * @param mapper a mapping function to apply to both values, if renderable
+ * @param type of the new condition
+ * @return a new condition with the result of applying the mappers to the values of this condition,
+ * if renderable, otherwise a condition that will not render.
+ */
+ AbstractTwoValueCondition map(Function super @NonNull T, ? extends R> mapper);
+ }
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/AliasableSqlTable.java b/src/main/java/org/mybatis/dynamic/sql/AliasableSqlTable.java
index 4e6c32386..915b6a561 100644
--- a/src/main/java/org/mybatis/dynamic/sql/AliasableSqlTable.java
+++ b/src/main/java/org/mybatis/dynamic/sql/AliasableSqlTable.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -19,9 +19,11 @@
import java.util.Optional;
import java.util.function.Supplier;
+import org.jspecify.annotations.Nullable;
+
public abstract class AliasableSqlTable> extends SqlTable {
- private String tableAlias;
+ private @Nullable String tableAlias;
private final Supplier constructor;
protected AliasableSqlTable(String tableName, Supplier constructor) {
@@ -32,7 +34,7 @@ protected AliasableSqlTable(String tableName, Supplier constructor) {
public T withAlias(String alias) {
T newTable = constructor.get();
((AliasableSqlTable) newTable).tableAlias = alias;
- newTable.nameSupplier = nameSupplier;
+ newTable.tableName = tableName;
return newTable;
}
@@ -48,7 +50,7 @@ public T withName(String name) {
Objects.requireNonNull(name);
T newTable = constructor.get();
((AliasableSqlTable) newTable).tableAlias = tableAlias;
- newTable.nameSupplier = () -> name;
+ newTable.tableName = name;
return newTable;
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/AndOrCriteriaGroup.java b/src/main/java/org/mybatis/dynamic/sql/AndOrCriteriaGroup.java
index a85861904..ff630a036 100644
--- a/src/main/java/org/mybatis/dynamic/sql/AndOrCriteriaGroup.java
+++ b/src/main/java/org/mybatis/dynamic/sql/AndOrCriteriaGroup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -21,6 +21,8 @@
import java.util.Objects;
import java.util.Optional;
+import org.jspecify.annotations.Nullable;
+
/**
* This class represents a criteria group with either an AND or an OR connector.
* This class is intentionally NOT derived from SqlCriterion because we only want it to be
@@ -32,7 +34,7 @@
*/
public class AndOrCriteriaGroup {
private final String connector;
- private final SqlCriterion initialCriterion;
+ private final @Nullable SqlCriterion initialCriterion;
private final List subCriteria;
private AndOrCriteriaGroup(Builder builder) {
@@ -54,8 +56,8 @@ public List subCriteria() {
}
public static class Builder {
- private String connector;
- private SqlCriterion initialCriterion;
+ private @Nullable String connector;
+ private @Nullable SqlCriterion initialCriterion;
private final List subCriteria = new ArrayList<>();
public Builder withConnector(String connector) {
@@ -63,7 +65,7 @@ public Builder withConnector(String connector) {
return this;
}
- public Builder withInitialCriterion(SqlCriterion initialCriterion) {
+ public Builder withInitialCriterion(@Nullable SqlCriterion initialCriterion) {
this.initialCriterion = initialCriterion;
return this;
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/BasicColumn.java b/src/main/java/org/mybatis/dynamic/sql/BasicColumn.java
index aaee827b1..2573b4529 100644
--- a/src/main/java/org/mybatis/dynamic/sql/BasicColumn.java
+++ b/src/main/java/org/mybatis/dynamic/sql/BasicColumn.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -15,13 +15,12 @@
*/
package org.mybatis.dynamic.sql;
+import java.sql.JDBCType;
import java.util.Optional;
-import org.mybatis.dynamic.sql.exception.DynamicSqlException;
import org.mybatis.dynamic.sql.render.RenderingContext;
-import org.mybatis.dynamic.sql.render.TableAliasCalculator;
+import org.mybatis.dynamic.sql.render.RenderingStrategy;
import org.mybatis.dynamic.sql.util.FragmentAndParameters;
-import org.mybatis.dynamic.sql.util.Messages;
/**
* Describes attributes of columns that are necessary for rendering if the column is not expected to
@@ -59,24 +58,18 @@ public interface BasicColumn {
* @return a rendered SQL fragment and, optionally, parameters associated with the fragment
* @since 1.5.1
*/
- default FragmentAndParameters render(RenderingContext renderingContext) {
- // the default implementation ensures compatibility with prior releases. When the
- // deprecated renderWithTableAlias method is removed, this function can become purely abstract.
- // Also remove the method tableAliasCalculator() from RenderingContext.
- return FragmentAndParameters.fromFragment(renderWithTableAlias(renderingContext.tableAliasCalculator()));
+ FragmentAndParameters render(RenderingContext renderingContext);
+
+ default Optional jdbcType() {
+ return Optional.empty();
}
- /**
- * Returns the name of the item aliased with a table name if appropriate.
- * For example, "a.foo". This is appropriate for where clauses and order by clauses.
- *
- * @param tableAliasCalculator the table alias calculator for the current renderer
- * @return the item name with the table alias applied
- * @deprecated Please replace this method by overriding the more general "render" method
- */
- @Deprecated
- default String renderWithTableAlias(TableAliasCalculator tableAliasCalculator) {
- throw new DynamicSqlException(Messages.getString("ERROR.36")); //$NON-NLS-1$
+ default Optional typeHandler() {
+ return Optional.empty();
+ }
+
+ default Optional renderingStrategy() {
+ return Optional.empty();
}
/**
diff --git a/src/main/java/org/mybatis/dynamic/sql/BindableColumn.java b/src/main/java/org/mybatis/dynamic/sql/BindableColumn.java
index 274b52e25..0fd90b7c8 100644
--- a/src/main/java/org/mybatis/dynamic/sql/BindableColumn.java
+++ b/src/main/java/org/mybatis/dynamic/sql/BindableColumn.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -15,14 +15,13 @@
*/
package org.mybatis.dynamic.sql;
-import java.sql.JDBCType;
import java.util.Optional;
-import org.mybatis.dynamic.sql.render.RenderingStrategy;
+import org.jspecify.annotations.Nullable;
/**
- * Describes additional attributes of columns that are necessary for binding the column as a JDBC parameter.
- * Columns in where clauses are typically bound.
+ * Describes a column with a known data type. The type is only used by the compiler to assure type safety
+ * when building clauses with conditions.
*
* @author Jeff Butler
*
@@ -37,19 +36,7 @@ public interface BindableColumn extends BasicColumn {
@Override
BindableColumn as(String alias);
- default Optional jdbcType() {
- return Optional.empty();
- }
-
- default Optional typeHandler() {
- return Optional.empty();
- }
-
- default Optional renderingStrategy() {
- return Optional.empty();
- }
-
- default Object convertParameterType(T value) {
+ default @Nullable Object convertParameterType(T value) {
return value;
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/BoundValue.java b/src/main/java/org/mybatis/dynamic/sql/BoundValue.java
index 7ac0bd26a..5151a5dad 100644
--- a/src/main/java/org/mybatis/dynamic/sql/BoundValue.java
+++ b/src/main/java/org/mybatis/dynamic/sql/BoundValue.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
diff --git a/src/main/java/org/mybatis/dynamic/sql/ColumnAndConditionCriterion.java b/src/main/java/org/mybatis/dynamic/sql/ColumnAndConditionCriterion.java
index 9c0f47151..053c18f64 100644
--- a/src/main/java/org/mybatis/dynamic/sql/ColumnAndConditionCriterion.java
+++ b/src/main/java/org/mybatis/dynamic/sql/ColumnAndConditionCriterion.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -17,9 +17,11 @@
import java.util.Objects;
+import org.jspecify.annotations.Nullable;
+
public class ColumnAndConditionCriterion extends SqlCriterion {
private final BindableColumn column;
- private final VisitableCondition condition;
+ private final RenderableCondition condition;
private ColumnAndConditionCriterion(Builder builder) {
super(builder);
@@ -31,7 +33,7 @@ public BindableColumn column() {
return column;
}
- public VisitableCondition condition() {
+ public RenderableCondition condition() {
return condition;
}
@@ -45,15 +47,15 @@ public static Builder withColumn(BindableColumn column) {
}
public static class Builder extends AbstractBuilder> {
- private BindableColumn column;
- private VisitableCondition condition;
+ private @Nullable BindableColumn column;
+ private @Nullable RenderableCondition condition;
public Builder withColumn(BindableColumn column) {
this.column = column;
return this;
}
- public Builder withCondition(VisitableCondition condition) {
+ public Builder withCondition(RenderableCondition condition) {
this.condition = condition;
return this;
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/ConditionVisitor.java b/src/main/java/org/mybatis/dynamic/sql/ConditionVisitor.java
deleted file mode 100644
index c8e95a9bd..000000000
--- a/src/main/java/org/mybatis/dynamic/sql/ConditionVisitor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2016-2024 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.
- * You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.mybatis.dynamic.sql;
-
-public interface ConditionVisitor {
- R visit(AbstractListValueCondition condition);
-
- R visit(AbstractNoValueCondition condition);
-
- R visit(AbstractSingleValueCondition condition);
-
- R visit(AbstractTwoValueCondition condition);
-
- R visit(AbstractSubselectCondition condition);
-
- R visit(AbstractColumnComparisonCondition condition);
-}
diff --git a/src/main/java/org/mybatis/dynamic/sql/Constant.java b/src/main/java/org/mybatis/dynamic/sql/Constant.java
index d424f6391..90547765f 100644
--- a/src/main/java/org/mybatis/dynamic/sql/Constant.java
+++ b/src/main/java/org/mybatis/dynamic/sql/Constant.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -18,19 +18,20 @@
import java.util.Objects;
import java.util.Optional;
+import org.jspecify.annotations.Nullable;
import org.mybatis.dynamic.sql.render.RenderingContext;
import org.mybatis.dynamic.sql.util.FragmentAndParameters;
public class Constant implements BindableColumn {
- private final String alias;
+ private final @Nullable String alias;
private final String value;
private Constant(String value) {
this(value, null);
}
- private Constant(String value, String alias) {
+ private Constant(String value, @Nullable String alias) {
this.value = Objects.requireNonNull(value);
this.alias = alias;
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/CriteriaGroup.java b/src/main/java/org/mybatis/dynamic/sql/CriteriaGroup.java
index 931b55722..476cb6b3f 100644
--- a/src/main/java/org/mybatis/dynamic/sql/CriteriaGroup.java
+++ b/src/main/java/org/mybatis/dynamic/sql/CriteriaGroup.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -17,6 +17,8 @@
import java.util.Optional;
+import org.jspecify.annotations.Nullable;
+
/**
* This class represents a criteria group without an AND or an OR connector. This is useful
* in situations where the initial SqlCriterion in a list should be further grouped
@@ -27,7 +29,7 @@
* @since 1.4.0
*/
public class CriteriaGroup extends SqlCriterion {
- private final SqlCriterion initialCriterion;
+ private final @Nullable SqlCriterion initialCriterion;
protected CriteriaGroup(AbstractGroupBuilder> builder) {
super(builder);
@@ -44,9 +46,9 @@ public R accept(SqlCriterionVisitor visitor) {
}
public abstract static class AbstractGroupBuilder> extends AbstractBuilder {
- private SqlCriterion initialCriterion;
+ private @Nullable SqlCriterion initialCriterion;
- public T withInitialCriterion(SqlCriterion initialCriterion) {
+ public T withInitialCriterion(@Nullable SqlCriterion initialCriterion) {
this.initialCriterion = initialCriterion;
return getThis();
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/DerivedColumn.java b/src/main/java/org/mybatis/dynamic/sql/DerivedColumn.java
index 73ca62526..df19b8d6b 100644
--- a/src/main/java/org/mybatis/dynamic/sql/DerivedColumn.java
+++ b/src/main/java/org/mybatis/dynamic/sql/DerivedColumn.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -19,6 +19,7 @@
import java.util.Objects;
import java.util.Optional;
+import org.jspecify.annotations.Nullable;
import org.mybatis.dynamic.sql.render.RenderingContext;
import org.mybatis.dynamic.sql.util.FragmentAndParameters;
@@ -34,10 +35,10 @@
*/
public class DerivedColumn implements BindableColumn {
private final String name;
- private final String tableQualifier;
- private final String columnAlias;
- private final JDBCType jdbcType;
- private final String typeHandler;
+ private final @Nullable String tableQualifier;
+ private final @Nullable String columnAlias;
+ private final @Nullable JDBCType jdbcType;
+ private final @Nullable String typeHandler;
protected DerivedColumn(Builder builder) {
this.name = Objects.requireNonNull(builder.name);
@@ -93,18 +94,18 @@ public static DerivedColumn of(String name, String tableQualifier) {
}
public static class Builder {
- private String name;
- private String tableQualifier;
- private String columnAlias;
- private JDBCType jdbcType;
- private String typeHandler;
+ private @Nullable String name;
+ private @Nullable String tableQualifier;
+ private @Nullable String columnAlias;
+ private @Nullable JDBCType jdbcType;
+ private @Nullable String typeHandler;
public Builder withName(String name) {
this.name = name;
return this;
}
- public Builder withTableQualifier(String tableQualifier) {
+ public Builder withTableQualifier(@Nullable String tableQualifier) {
this.tableQualifier = tableQualifier;
return this;
}
@@ -114,12 +115,12 @@ public Builder withColumnAlias(String columnAlias) {
return this;
}
- public Builder withJdbcType(JDBCType jdbcType) {
+ public Builder withJdbcType(@Nullable JDBCType jdbcType) {
this.jdbcType = jdbcType;
return this;
}
- public Builder withTypeHandler(String typeHandler) {
+ public Builder withTypeHandler(@Nullable String typeHandler) {
this.typeHandler = typeHandler;
return this;
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/ExistsCriterion.java b/src/main/java/org/mybatis/dynamic/sql/ExistsCriterion.java
index 711b85ffd..17cecdaa6 100644
--- a/src/main/java/org/mybatis/dynamic/sql/ExistsCriterion.java
+++ b/src/main/java/org/mybatis/dynamic/sql/ExistsCriterion.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -17,6 +17,8 @@
import java.util.Objects;
+import org.jspecify.annotations.Nullable;
+
public class ExistsCriterion extends SqlCriterion {
private final ExistsPredicate existsPredicate;
@@ -35,7 +37,7 @@ public R accept(SqlCriterionVisitor visitor) {
}
public static class Builder extends AbstractBuilder {
- private ExistsPredicate existsPredicate;
+ private @Nullable ExistsPredicate existsPredicate;
public Builder withExistsPredicate(ExistsPredicate existsPredicate) {
this.existsPredicate = existsPredicate;
diff --git a/src/main/java/org/mybatis/dynamic/sql/ExistsPredicate.java b/src/main/java/org/mybatis/dynamic/sql/ExistsPredicate.java
index 8d68a3ac9..c22a84aa2 100644
--- a/src/main/java/org/mybatis/dynamic/sql/ExistsPredicate.java
+++ b/src/main/java/org/mybatis/dynamic/sql/ExistsPredicate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -17,7 +17,6 @@
import java.util.Objects;
-import org.jetbrains.annotations.NotNull;
import org.mybatis.dynamic.sql.select.SelectModel;
import org.mybatis.dynamic.sql.util.Buildable;
@@ -38,12 +37,10 @@ public Buildable selectModelBuilder() {
return selectModelBuilder;
}
- @NotNull
public static ExistsPredicate exists(Buildable selectModelBuilder) {
return new ExistsPredicate("exists", selectModelBuilder); //$NON-NLS-1$
}
- @NotNull
public static ExistsPredicate notExists(Buildable selectModelBuilder) {
return new ExistsPredicate("not exists", selectModelBuilder); //$NON-NLS-1$
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/NotCriterion.java b/src/main/java/org/mybatis/dynamic/sql/NotCriterion.java
index cd9f5e980..f0a0010f8 100644
--- a/src/main/java/org/mybatis/dynamic/sql/NotCriterion.java
+++ b/src/main/java/org/mybatis/dynamic/sql/NotCriterion.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
diff --git a/src/main/java/org/mybatis/dynamic/sql/ParameterTypeConverter.java b/src/main/java/org/mybatis/dynamic/sql/ParameterTypeConverter.java
index 7df7572b1..4f4856e19 100644
--- a/src/main/java/org/mybatis/dynamic/sql/ParameterTypeConverter.java
+++ b/src/main/java/org/mybatis/dynamic/sql/ParameterTypeConverter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -15,6 +15,8 @@
*/
package org.mybatis.dynamic.sql;
+import org.jspecify.annotations.Nullable;
+
/**
* A parameter type converter is used to change a parameter value from one type to another
* during statement rendering and before the parameter is placed into the parameter map. This can be used
@@ -50,5 +52,13 @@
*/
@FunctionalInterface
public interface ParameterTypeConverter {
- T convert(S source);
+ /**
+ * Convert the value from one value to another.
+ *
+ * The input value will never be null - the framework will automatically handle nulls.
+ *
+ * @param source value as specified in the condition, or after a map operation. Never null.
+ * @return Possibly null converted value.
+ */
+ @Nullable T convert(S source);
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/RenderableCondition.java b/src/main/java/org/mybatis/dynamic/sql/RenderableCondition.java
new file mode 100644
index 000000000..51dc912e8
--- /dev/null
+++ b/src/main/java/org/mybatis/dynamic/sql/RenderableCondition.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2016-2025 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.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.mybatis.dynamic.sql;
+
+import org.mybatis.dynamic.sql.render.RenderingContext;
+import org.mybatis.dynamic.sql.util.FragmentAndParameters;
+
+@FunctionalInterface
+public interface RenderableCondition {
+ /**
+ * Render a condition - typically a condition in a WHERE clause.
+ *
+ * A rendered condition includes an SQL fragment, and any associated parameters. For example,
+ * the isEqual
condition should be rendered as "= ?" where "?" is a properly formatted
+ * parameter marker (the parameter marker can be computed from the RenderingContext
).
+ * Note that a rendered condition should NOT include the left side of the phrase - that is rendered
+ * by the {@link RenderableCondition#renderLeftColumn(RenderingContext, BindableColumn)} method.
+ *
+ * @param renderingContext the current rendering context
+ * @param leftColumn the column related to this condition in a where clause
+ * @return the rendered condition. Should NOT include the column.
+ */
+ FragmentAndParameters renderCondition(RenderingContext renderingContext, BindableColumn leftColumn);
+
+ /**
+ * Render the column in a column and condition phrase - typically in a WHERE clause.
+ *
+ * By default, the column will be rendered as the column alias if it exists, or the column name.
+ * This can be complicated if the column has a table qualifier, or if the "column" is a function or
+ * part of a CASE expression. Columns know how to render themselves, so we just call their "render"
+ * methods.
+ *
+ * @param renderingContext the current rendering context
+ * @param leftColumn the column related to this condition in a where clause
+ * @return the rendered column
+ */
+ default FragmentAndParameters renderLeftColumn(RenderingContext renderingContext, BindableColumn leftColumn) {
+ return leftColumn.alias()
+ .map(FragmentAndParameters::fromFragment)
+ .orElseGet(() -> leftColumn.render(renderingContext));
+ }
+
+ /**
+ * Subclasses can override this to inform the renderer if the condition should not be included
+ * in the rendered SQL. Typically, conditions will not render if they are empty.
+ *
+ * @return true if the condition should render.
+ */
+ default boolean shouldRender(RenderingContext renderingContext) {
+ return !isEmpty();
+ }
+
+ /**
+ * Subclasses can override this to indicate whether the condition is considered empty. This is primarily used in
+ * map and filter operations - the map and filter functions will not be applied if the condition is empty.
+ *
+ * @return true if the condition is empty.
+ */
+ default boolean isEmpty() {
+ return false;
+ }
+
+ /**
+ * This method will be called during rendering when {@link RenderableCondition#shouldRender(RenderingContext)}
+ * returns false.
+ */
+ default void renderingSkipped() {}
+}
diff --git a/src/main/java/org/mybatis/dynamic/sql/SortSpecification.java b/src/main/java/org/mybatis/dynamic/sql/SortSpecification.java
index a17557017..13cfdee55 100644
--- a/src/main/java/org/mybatis/dynamic/sql/SortSpecification.java
+++ b/src/main/java/org/mybatis/dynamic/sql/SortSpecification.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -15,6 +15,9 @@
*/
package org.mybatis.dynamic.sql;
+import org.mybatis.dynamic.sql.render.RenderingContext;
+import org.mybatis.dynamic.sql.util.FragmentAndParameters;
+
/**
* Defines attributes of columns that are necessary for rendering an order by expression.
*
@@ -30,17 +33,12 @@ public interface SortSpecification {
SortSpecification descending();
/**
- * Return the phrase that should be written into a rendered order by clause. This should
- * NOT include the "DESC" word for descending sort specifications.
- *
- * @return the order by phrase
- */
- String orderByName();
-
- /**
- * Return true if the sort order is descending.
+ * Return a fragment rendered for use in an ORDER BY clause. The fragment should include "DESC" if a
+ * descending order is desired.
*
- * @return true if the SortSpecification should render as descending
+ * @param renderingContext the current rendering context
+ * @return a rendered fragment and parameters if applicable
+ * @since 2.0.0
*/
- boolean isDescending();
+ FragmentAndParameters renderForOrderBy(RenderingContext renderingContext);
}
diff --git a/src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java b/src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java
index 6516696f6..c8fe5c3ba 100644
--- a/src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java
+++ b/src/main/java/org/mybatis/dynamic/sql/SqlBuilder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2016-2024 the original author or authors.
+ * Copyright 2016-2025 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.
@@ -21,6 +21,8 @@
import java.util.Objects;
import java.util.function.Supplier;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.Nullable;
import org.mybatis.dynamic.sql.delete.DeleteDSL;
import org.mybatis.dynamic.sql.delete.DeleteModel;
import org.mybatis.dynamic.sql.insert.BatchInsertDSL;
@@ -56,23 +58,23 @@
import org.mybatis.dynamic.sql.select.function.Substring;
import org.mybatis.dynamic.sql.select.function.Subtract;
import org.mybatis.dynamic.sql.select.function.Upper;
-import org.mybatis.dynamic.sql.select.join.EqualTo;
-import org.mybatis.dynamic.sql.select.join.EqualToValue;
-import org.mybatis.dynamic.sql.select.join.JoinCondition;
-import org.mybatis.dynamic.sql.select.join.JoinCriterion;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.util.Buildable;
import org.mybatis.dynamic.sql.where.WhereDSL;
import org.mybatis.dynamic.sql.where.condition.IsBetween;
+import org.mybatis.dynamic.sql.where.condition.IsBetweenWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsEqualTo;
import org.mybatis.dynamic.sql.where.condition.IsEqualToColumn;
+import org.mybatis.dynamic.sql.where.condition.IsEqualToWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsEqualToWithSubselect;
import org.mybatis.dynamic.sql.where.condition.IsGreaterThan;
import org.mybatis.dynamic.sql.where.condition.IsGreaterThanColumn;
import org.mybatis.dynamic.sql.where.condition.IsGreaterThanOrEqualTo;
import org.mybatis.dynamic.sql.where.condition.IsGreaterThanOrEqualToColumn;
+import org.mybatis.dynamic.sql.where.condition.IsGreaterThanOrEqualToWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsGreaterThanOrEqualToWithSubselect;
+import org.mybatis.dynamic.sql.where.condition.IsGreaterThanWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsGreaterThanWithSubselect;
import org.mybatis.dynamic.sql.where.condition.IsIn;
import org.mybatis.dynamic.sql.where.condition.IsInCaseInsensitive;
@@ -83,13 +85,19 @@
import org.mybatis.dynamic.sql.where.condition.IsLessThanColumn;
import org.mybatis.dynamic.sql.where.condition.IsLessThanOrEqualTo;
import org.mybatis.dynamic.sql.where.condition.IsLessThanOrEqualToColumn;
+import org.mybatis.dynamic.sql.where.condition.IsLessThanOrEqualToWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsLessThanOrEqualToWithSubselect;
+import org.mybatis.dynamic.sql.where.condition.IsLessThanWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsLessThanWithSubselect;
import org.mybatis.dynamic.sql.where.condition.IsLike;
import org.mybatis.dynamic.sql.where.condition.IsLikeCaseInsensitive;
+import org.mybatis.dynamic.sql.where.condition.IsLikeCaseInsensitiveWhenPresent;
+import org.mybatis.dynamic.sql.where.condition.IsLikeWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsNotBetween;
+import org.mybatis.dynamic.sql.where.condition.IsNotBetweenWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsNotEqualTo;
import org.mybatis.dynamic.sql.where.condition.IsNotEqualToColumn;
+import org.mybatis.dynamic.sql.where.condition.IsNotEqualToWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsNotEqualToWithSubselect;
import org.mybatis.dynamic.sql.where.condition.IsNotIn;
import org.mybatis.dynamic.sql.where.condition.IsNotInCaseInsensitive;
@@ -98,6 +106,8 @@
import org.mybatis.dynamic.sql.where.condition.IsNotInWithSubselect;
import org.mybatis.dynamic.sql.where.condition.IsNotLike;
import org.mybatis.dynamic.sql.where.condition.IsNotLikeCaseInsensitive;
+import org.mybatis.dynamic.sql.where.condition.IsNotLikeCaseInsensitiveWhenPresent;
+import org.mybatis.dynamic.sql.where.condition.IsNotLikeWhenPresent;
import org.mybatis.dynamic.sql.where.condition.IsNotNull;
import org.mybatis.dynamic.sql.where.condition.IsNull;
@@ -253,7 +263,7 @@ static WhereDSL.StandaloneWhereFinisher where() {
return new WhereDSL().where();
}
- static WhereDSL.StandaloneWhereFinisher where(BindableColumn column, VisitableCondition condition,
+ static WhereDSL.StandaloneWhereFinisher where(BindableColumn column, RenderableCondition condition,
AndOrCriteriaGroup... subCriteria) {
return new WhereDSL().where(column, condition, subCriteria);
}
@@ -266,7 +276,7 @@ static WhereDSL.StandaloneWhereFinisher where(ExistsPredicate existsPredicate, A
return new WhereDSL().where(existsPredicate, subCriteria);
}
- static HavingDSL.StandaloneHavingFinisher having(BindableColumn column, VisitableCondition condition,
+ static HavingDSL.StandaloneHavingFinisher having(BindableColumn column, RenderableCondition condition,
AndOrCriteriaGroup... subCriteria) {
return new HavingDSL().having(column, condition, subCriteria);
}
@@ -276,12 +286,12 @@ static HavingDSL.StandaloneHavingFinisher having(SqlCriterion initialCriterion,
}
// where condition connectors
- static CriteriaGroup group(BindableColumn column, VisitableCondition condition,
+ static CriteriaGroup group(BindableColumn column, RenderableCondition condition,
AndOrCriteriaGroup... subCriteria) {
return group(column, condition, Arrays.asList(subCriteria));
}
- static CriteriaGroup group(BindableColumn column, VisitableCondition condition,
+ static CriteriaGroup group(BindableColumn column, RenderableCondition condition,
List subCriteria) {
return new CriteriaGroup.Builder()
.withInitialCriterion(new ColumnAndConditionCriterion.Builder().withColumn(column)
@@ -319,12 +329,12 @@ static CriteriaGroup group(List subCriteria) {
.build();
}
- static NotCriterion not(BindableColumn column, VisitableCondition condition,
+ static NotCriterion not(BindableColumn column, RenderableCondition condition,
AndOrCriteriaGroup... subCriteria) {
return not(column, condition, Arrays.asList(subCriteria));
}
- static NotCriterion not(BindableColumn column, VisitableCondition condition,
+ static NotCriterion not(BindableColumn column, RenderableCondition condition,
List subCriteria) {
return new NotCriterion.Builder()
.withInitialCriterion(new ColumnAndConditionCriterion.Builder().withColumn(column)
@@ -362,7 +372,7 @@ static NotCriterion not(List subCriteria) {
.build();
}
- static AndOrCriteriaGroup or(BindableColumn column, VisitableCondition condition,
+ static AndOrCriteriaGroup or(BindableColumn column, RenderableCondition condition,
AndOrCriteriaGroup... subCriteria) {
return new AndOrCriteriaGroup.Builder()
.withInitialCriterion(ColumnAndConditionCriterion.withColumn(column)
@@ -397,7 +407,7 @@ static AndOrCriteriaGroup or(List subCriteria) {
.build();
}
- static AndOrCriteriaGroup and(BindableColumn column, VisitableCondition condition,
+ static AndOrCriteriaGroup and(BindableColumn column, RenderableCondition condition,
AndOrCriteriaGroup... subCriteria) {
return new AndOrCriteriaGroup.Builder()
.withInitialCriterion(ColumnAndConditionCriterion.withColumn(column)
@@ -433,20 +443,36 @@ static AndOrCriteriaGroup and(List subCriteria) {
}
// join support
- static JoinCriterion and(BindableColumn joinColumn, JoinCondition joinCondition) {
- return new JoinCriterion.Builder()
- .withConnector("and") //$NON-NLS-1$
- .withJoinColumn(joinColumn)
- .withJoinCondition(joinCondition)
+ static ColumnAndConditionCriterion on(BindableColumn joinColumn, RenderableCondition joinCondition) {
+ return ColumnAndConditionCriterion.withColumn(joinColumn)
+ .withCondition(joinCondition)
.build();
}
- static