Package org.mybatis.dynamic.sql
Interface SqlBuilder
public interface SqlBuilder
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic class
static class
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Add
<T> add
(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) static AndOrCriteriaGroup
and
(List<AndOrCriteriaGroup> subCriteria) static <T> JoinCriterion
<T> and
(BindableColumn<T> joinColumn, JoinCondition<T> joinCondition) static <T> AndOrCriteriaGroup
and
(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) static AndOrCriteriaGroup
and
(ExistsPredicate existsPredicate, AndOrCriteriaGroup... subCriteria) static AndOrCriteriaGroup
and
(SqlCriterion initialCriterion, AndOrCriteriaGroup... subCriteria) static <T> OperatorFunction
<T> applyOperator
(String operator, BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) static <T> Avg
<T> avg
(BindableColumn<T> column) static SearchedCaseDSL
case_()
static <T> SimpleCaseDSL
<T> case_
(BindableColumn<T> column) static SqlBuilder.CastFinisher
static SqlBuilder.CastFinisher
static SqlBuilder.CastFinisher
cast
(BasicColumn column) static <T> Concat
<T> concat
(BindableColumn<T> firstColumn, BasicColumn... subsequentColumns) Concatenate function that renders as "concat(x, y, z)".static <T> Concatenate
<T> concatenate
(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) Concatenate function that renders as "(x || y || z)".static <T> Constant
<T> static CountAll
count()
static Count
count
(BasicColumn column) static CountDSL.FromGatherer
<SelectModel> countColumn
(BasicColumn column) Renders as select count(column) from table...static CountDistinct
countDistinct
(BasicColumn column) static CountDSL.FromGatherer
<SelectModel> countDistinctColumn
(BasicColumn column) Renders as select count(distinct column) from table...static CountDSL
<SelectModel> Renders as select count(*) from table...static DeleteDSL
<DeleteModel> deleteFrom
(SqlTable table) static DeleteDSL
<DeleteModel> deleteFrom
(SqlTable table, String tableAlias) static <T> Divide
<T> divide
(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) static <T> EqualTo
<T> equalTo
(BindableColumn<T> column) static <T> EqualToValue
<T> equalTo
(T value) static ExistsPredicate
exists
(Buildable<SelectModel> selectModelBuilder) static CriteriaGroup
group
(List<AndOrCriteriaGroup> subCriteria) static <T> CriteriaGroup
group
(BindableColumn<T> column, VisitableCondition<T> condition, List<AndOrCriteriaGroup> subCriteria) static <T> CriteriaGroup
group
(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) static CriteriaGroup
group
(ExistsPredicate existsPredicate, List<AndOrCriteriaGroup> subCriteria) static CriteriaGroup
group
(ExistsPredicate existsPredicate, AndOrCriteriaGroup... subCriteria) static CriteriaGroup
group
(SqlCriterion initialCriterion, List<AndOrCriteriaGroup> subCriteria) static CriteriaGroup
group
(SqlCriterion initialCriterion, AndOrCriteriaGroup... subCriteria) static <T> HavingDSL.StandaloneHavingFinisher
having
(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) having
(SqlCriterion initialCriterion, AndOrCriteriaGroup... subCriteria) static <T> InsertDSL.IntoGatherer
<T> insert
(T row) static <T> BatchInsertDSL.IntoGatherer
<T> insertBatch
(Collection<T> records) Insert a Batch of records.static <T> BatchInsertDSL.IntoGatherer
<T> insertBatch
(T... records) Insert a Batch of records.insertInto
(SqlTable table) static <T> MultiRowInsertDSL.IntoGatherer
<T> insertMultiple
(Collection<T> records) Insert multiple records in a single statement.static <T> MultiRowInsertDSL.IntoGatherer
<T> insertMultiple
(T... records) Insert multiple records in a single statement.static <T> IsBetween.Builder
<T> static <T> IsBetween.Builder
<T> isBetween
(T value1) static <T> IsBetween.WhenPresentBuilder
<T> isBetweenWhenPresent
(Supplier<T> valueSupplier1) static <T> IsBetween.WhenPresentBuilder
<T> isBetweenWhenPresent
(T value1) static <T> IsEqualTo
<T> static <T> IsEqualToColumn
<T> isEqualTo
(BasicColumn column) static <T> IsEqualToWithSubselect
<T> isEqualTo
(Buildable<SelectModel> selectModelBuilder) static <T> IsEqualTo
<T> isEqualTo
(T value) static <T> IsEqualTo
<T> isEqualToWhenPresent
(Supplier<T> valueSupplier) static <T> IsEqualTo
<T> isEqualToWhenPresent
(T value) isFalse()
static <T> IsGreaterThan
<T> isGreaterThan
(Supplier<T> valueSupplier) static <T> IsGreaterThanColumn
<T> isGreaterThan
(BasicColumn column) static <T> IsGreaterThanWithSubselect
<T> isGreaterThan
(Buildable<SelectModel> selectModelBuilder) static <T> IsGreaterThan
<T> isGreaterThan
(T value) static <T> IsGreaterThanOrEqualTo
<T> isGreaterThanOrEqualTo
(Supplier<T> valueSupplier) static <T> IsGreaterThanOrEqualToColumn
<T> isGreaterThanOrEqualTo
(BasicColumn column) static <T> IsGreaterThanOrEqualToWithSubselect
<T> isGreaterThanOrEqualTo
(Buildable<SelectModel> selectModelBuilder) static <T> IsGreaterThanOrEqualTo
<T> isGreaterThanOrEqualTo
(T value) static <T> IsGreaterThanOrEqualTo
<T> isGreaterThanOrEqualToWhenPresent
(Supplier<T> valueSupplier) static <T> IsGreaterThanOrEqualTo
<T> isGreaterThanOrEqualToWhenPresent
(T value) static <T> IsGreaterThan
<T> isGreaterThanWhenPresent
(Supplier<T> valueSupplier) static <T> IsGreaterThan
<T> isGreaterThanWhenPresent
(T value) static <T> IsIn
<T> isIn
(Collection<T> values) static <T> IsInWithSubselect
<T> isIn
(Buildable<SelectModel> selectModelBuilder) static <T> IsIn
<T> isIn
(T... values) static IsInCaseInsensitive
isInCaseInsensitive
(String... values) static IsInCaseInsensitive
isInCaseInsensitive
(Collection<String> values) isInCaseInsensitiveWhenPresent
(String... values) static <T> IsInWhenPresent
<T> isInWhenPresent
(Collection<T> values) static <T> IsInWhenPresent
<T> isInWhenPresent
(T... values) static <T> IsLessThan
<T> isLessThan
(Supplier<T> valueSupplier) static <T> IsLessThanColumn
<T> isLessThan
(BasicColumn column) static <T> IsLessThanWithSubselect
<T> isLessThan
(Buildable<SelectModel> selectModelBuilder) static <T> IsLessThan
<T> isLessThan
(T value) static <T> IsLessThanOrEqualTo
<T> isLessThanOrEqualTo
(Supplier<T> valueSupplier) static <T> IsLessThanOrEqualToColumn
<T> isLessThanOrEqualTo
(BasicColumn column) static <T> IsLessThanOrEqualToWithSubselect
<T> isLessThanOrEqualTo
(Buildable<SelectModel> selectModelBuilder) static <T> IsLessThanOrEqualTo
<T> isLessThanOrEqualTo
(T value) static <T> IsLessThanOrEqualTo
<T> isLessThanOrEqualToWhenPresent
(Supplier<T> valueSupplier) static <T> IsLessThanOrEqualTo
<T> isLessThanOrEqualToWhenPresent
(T value) static <T> IsLessThan
<T> isLessThanWhenPresent
(Supplier<T> valueSupplier) static <T> IsLessThan
<T> isLessThanWhenPresent
(T value) static <T> IsLike
<T> static <T> IsLike
<T> isLike
(T value) static IsLikeCaseInsensitive
isLikeCaseInsensitive
(String value) static IsLikeCaseInsensitive
isLikeCaseInsensitive
(Supplier<String> valueSupplier) static IsLikeCaseInsensitive
static IsLikeCaseInsensitive
isLikeCaseInsensitiveWhenPresent
(Supplier<String> valueSupplier) static <T> IsLike
<T> isLikeWhenPresent
(Supplier<T> valueSupplier) static <T> IsLike
<T> isLikeWhenPresent
(T value) static <T> IsNotBetween.Builder
<T> isNotBetween
(Supplier<T> valueSupplier1) static <T> IsNotBetween.Builder
<T> isNotBetween
(T value1) static <T> IsNotBetween.WhenPresentBuilder
<T> isNotBetweenWhenPresent
(Supplier<T> valueSupplier1) static <T> IsNotBetween.WhenPresentBuilder
<T> isNotBetweenWhenPresent
(T value1) static <T> IsNotEqualTo
<T> isNotEqualTo
(Supplier<T> valueSupplier) static <T> IsNotEqualToColumn
<T> isNotEqualTo
(BasicColumn column) static <T> IsNotEqualToWithSubselect
<T> isNotEqualTo
(Buildable<SelectModel> selectModelBuilder) static <T> IsNotEqualTo
<T> isNotEqualTo
(T value) static <T> IsNotEqualTo
<T> isNotEqualToWhenPresent
(Supplier<T> valueSupplier) static <T> IsNotEqualTo
<T> isNotEqualToWhenPresent
(T value) static <T> IsNotIn
<T> isNotIn
(Collection<T> values) static <T> IsNotInWithSubselect
<T> isNotIn
(Buildable<SelectModel> selectModelBuilder) static <T> IsNotIn
<T> isNotIn
(T... values) static IsNotInCaseInsensitive
isNotInCaseInsensitive
(String... values) static IsNotInCaseInsensitive
isNotInCaseInsensitive
(Collection<String> values) isNotInCaseInsensitiveWhenPresent
(String... values) static <T> IsNotInWhenPresent
<T> isNotInWhenPresent
(Collection<T> values) static <T> IsNotInWhenPresent
<T> isNotInWhenPresent
(T... values) static <T> IsNotLike
<T> static <T> IsNotLike
<T> isNotLike
(T value) static IsNotLikeCaseInsensitive
isNotLikeCaseInsensitive
(String value) static IsNotLikeCaseInsensitive
isNotLikeCaseInsensitive
(Supplier<String> valueSupplier) static IsNotLikeCaseInsensitive
static IsNotLikeCaseInsensitive
isNotLikeCaseInsensitiveWhenPresent
(Supplier<String> valueSupplier) static <T> IsNotLike
<T> isNotLikeWhenPresent
(Supplier<T> valueSupplier) static <T> IsNotLike
<T> isNotLikeWhenPresent
(T value) static <T> IsNotNull
<T> static <T> IsNull
<T> isNull()
isTrue()
static <T> Lower
<T> lower
(BindableColumn<T> column) static <T> Max
<T> max
(BindableColumn<T> column) static <T> Min
<T> min
(BindableColumn<T> column) static <T> Multiply
<T> multiply
(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) static MultiSelectDSL
multiSelect
(Buildable<SelectModel> selectModelBuilder) static NotCriterion
not
(List<AndOrCriteriaGroup> subCriteria) static <T> NotCriterion
not
(BindableColumn<T> column, VisitableCondition<T> condition, List<AndOrCriteriaGroup> subCriteria) static <T> NotCriterion
not
(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) static NotCriterion
not
(ExistsPredicate existsPredicate, List<AndOrCriteriaGroup> subCriteria) static NotCriterion
not
(ExistsPredicate existsPredicate, AndOrCriteriaGroup... subCriteria) static NotCriterion
not
(SqlCriterion initialCriterion, List<AndOrCriteriaGroup> subCriteria) static NotCriterion
not
(SqlCriterion initialCriterion, AndOrCriteriaGroup... subCriteria) static ExistsPredicate
notExists
(Buildable<SelectModel> selectModelBuilder) static <T> JoinCriterion
<T> on
(BindableColumn<T> joinColumn, JoinCondition<T> joinCondition) static AndOrCriteriaGroup
or
(List<AndOrCriteriaGroup> subCriteria) static <T> AndOrCriteriaGroup
or
(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) static AndOrCriteriaGroup
or
(ExistsPredicate existsPredicate, AndOrCriteriaGroup... subCriteria) static AndOrCriteriaGroup
or
(SqlCriterion initialCriterion, AndOrCriteriaGroup... subCriteria) select
(Collection<? extends BasicColumn> selectList) select
(BasicColumn... selectList) selectDistinct
(Collection<? extends BasicColumn> selectList) selectDistinct
(BasicColumn... selectList) static SortSpecification
sortColumn
(String name) Creates a sort specification based on a String.static SortSpecification
sortColumn
(String tableAlias, SqlColumn<?> column) Creates a sort specification based on a column and a table alias.static StringConstant
stringConstant
(String constant) static <T> Substring
<T> substring
(BindableColumn<T> column, int offset, int length) static <T> Subtract
<T> subtract
(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) static <T> Sum
<T> sum
(BindableColumn<T> column) static <T> Sum
<T> sum
(BindableColumn<T> column, VisitableCondition<T> condition) static UpdateDSL
<UpdateModel> static UpdateDSL
<UpdateModel> static <T> Upper
<T> upper
(BindableColumn<T> column) static <T> BoundValue
<T> value
(T value) where()
static <T> WhereDSL.StandaloneWhereFinisher
where
(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) where
(ExistsPredicate existsPredicate, AndOrCriteriaGroup... subCriteria) where
(SqlCriterion initialCriterion, AndOrCriteriaGroup... subCriteria)
-
Method Details
-
countDistinctColumn
Renders as select count(distinct column) from table...- Parameters:
column
- the column to count- Returns:
- the next step in the DSL
-
countColumn
Renders as select count(column) from table...- Parameters:
column
- the column to count- Returns:
- the next step in the DSL
-
countFrom
Renders as select count(*) from table...- Parameters:
table
- the table to count- Returns:
- the next step in the DSL
-
deleteFrom
-
deleteFrom
-
insert
-
insertBatch
Insert a Batch of records. The model object is structured to support bulk inserts with JDBC batch support.- Type Parameters:
T
- the type of record to insert- Parameters:
records
- records to insert- Returns:
- the next step in the DSL
-
insertBatch
Insert a Batch of records. The model object is structured to support bulk inserts with JDBC batch support.- Type Parameters:
T
- the type of record to insert- Parameters:
records
- records to insert- Returns:
- the next step in the DSL
-
insertMultiple
Insert multiple records in a single statement. The model object is structured as a single insert statement with multiple values clauses. This statement is suitable for use with a small number of records. It is not suitable for large bulk inserts as it is possible to exceed the limit of parameter markers in a prepared statement.For large bulk inserts, see
insertBatch(Object[])
- Type Parameters:
T
- the type of record to insert- Parameters:
records
- records to insert- Returns:
- the next step in the DSL
-
insertMultiple
Insert multiple records in a single statement. The model object is structured as a single insert statement with multiple values clauses. This statement is suitable for use with a small number of records. It is not suitable for large bulk inserts as it is possible to exceed the limit of parameter markers in a prepared statement.For large bulk inserts, see
insertBatch(Collection)
- Type Parameters:
T
- the type of record to insert- Parameters:
records
- records to insert- Returns:
- the next step in the DSL
-
insertInto
-
select
-
select
static QueryExpressionDSL.FromGatherer<SelectModel> select(Collection<? extends BasicColumn> selectList) -
selectDistinct
-
selectDistinct
static QueryExpressionDSL.FromGatherer<SelectModel> selectDistinct(Collection<? extends BasicColumn> selectList) -
multiSelect
-
update
-
update
-
where
-
where
static <T> WhereDSL.StandaloneWhereFinisher where(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) -
where
static WhereDSL.StandaloneWhereFinisher where(SqlCriterion initialCriterion, AndOrCriteriaGroup... subCriteria) -
where
static WhereDSL.StandaloneWhereFinisher where(ExistsPredicate existsPredicate, AndOrCriteriaGroup... subCriteria) -
having
static <T> HavingDSL.StandaloneHavingFinisher having(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) -
having
static HavingDSL.StandaloneHavingFinisher having(SqlCriterion initialCriterion, AndOrCriteriaGroup... subCriteria) -
group
static <T> CriteriaGroup group(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) -
group
static <T> CriteriaGroup group(BindableColumn<T> column, VisitableCondition<T> condition, List<AndOrCriteriaGroup> subCriteria) -
group
-
group
-
group
-
group
-
group
-
not
static <T> NotCriterion not(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) -
not
static <T> NotCriterion not(BindableColumn<T> column, VisitableCondition<T> condition, List<AndOrCriteriaGroup> subCriteria) -
not
-
not
-
not
-
not
-
not
-
or
static <T> AndOrCriteriaGroup or(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) -
or
-
or
-
or
-
and
static <T> AndOrCriteriaGroup and(BindableColumn<T> column, VisitableCondition<T> condition, AndOrCriteriaGroup... subCriteria) -
and
-
and
-
and
-
and
-
on
-
case_
-
case_
-
equalTo
-
equalTo
-
count
-
count
-
countDistinct
-
max
-
min
-
avg
-
sum
-
sum
-
constant
-
stringConstant
-
value
-
add
static <T> Add<T> add(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) -
divide
static <T> Divide<T> divide(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) -
multiply
static <T> Multiply<T> multiply(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) -
subtract
static <T> Subtract<T> subtract(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) -
cast
-
cast
-
cast
-
concatenate
static <T> Concatenate<T> concatenate(BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) Concatenate function that renders as "(x || y || z)". This will not work on some databases like MySql. In that case, useconcat(BindableColumn, BasicColumn...)
- Type Parameters:
T
- type of column- Parameters:
firstColumn
- first columnsecondColumn
- second columnsubsequentColumns
- subsequent columns- Returns:
- a Concatenate instance
-
concat
Concatenate function that renders as "concat(x, y, z)". This version works on more databases thanconcatenate(BindableColumn, BasicColumn, BasicColumn...)
- Type Parameters:
T
- type of column- Parameters:
firstColumn
- first columnsubsequentColumns
- subsequent columns- Returns:
- a Concat instance
-
applyOperator
static <T> OperatorFunction<T> applyOperator(String operator, BindableColumn<T> firstColumn, BasicColumn secondColumn, BasicColumn... subsequentColumns) -
lower
-
substring
-
upper
-
exists
-
notExists
-
isNull
-
isNotNull
-
isEqualTo
-
isEqualTo
-
isEqualTo
-
isEqualTo
-
isEqualToWhenPresent
-
isEqualToWhenPresent
-
isNotEqualTo
-
isNotEqualTo
-
isNotEqualTo
-
isNotEqualTo
-
isNotEqualToWhenPresent
-
isNotEqualToWhenPresent
-
isGreaterThan
-
isGreaterThan
-
isGreaterThan
-
isGreaterThan
-
isGreaterThanWhenPresent
-
isGreaterThanWhenPresent
-
isGreaterThanOrEqualTo
-
isGreaterThanOrEqualTo
-
isGreaterThanOrEqualTo
static <T> IsGreaterThanOrEqualToWithSubselect<T> isGreaterThanOrEqualTo(Buildable<SelectModel> selectModelBuilder) -
isGreaterThanOrEqualTo
-
isGreaterThanOrEqualToWhenPresent
-
isGreaterThanOrEqualToWhenPresent
-
isLessThan
-
isLessThan
-
isLessThan
-
isLessThan
-
isLessThanWhenPresent
-
isLessThanWhenPresent
-
isLessThanOrEqualTo
-
isLessThanOrEqualTo
-
isLessThanOrEqualTo
static <T> IsLessThanOrEqualToWithSubselect<T> isLessThanOrEqualTo(Buildable<SelectModel> selectModelBuilder) -
isLessThanOrEqualTo
-
isLessThanOrEqualToWhenPresent
-
isLessThanOrEqualToWhenPresent
-
isIn
-
isIn
-
isIn
-
isInWhenPresent
-
isInWhenPresent
-
isNotIn
-
isNotIn
-
isNotIn
-
isNotInWhenPresent
-
isNotInWhenPresent
-
isBetween
-
isBetween
-
isBetweenWhenPresent
-
isBetweenWhenPresent
-
isNotBetween
-
isNotBetween
-
isNotBetweenWhenPresent
-
isNotBetweenWhenPresent
-
isLike
-
isLike
-
isLikeWhenPresent
-
isLikeWhenPresent
-
isNotLike
-
isNotLike
-
isNotLikeWhenPresent
-
isNotLikeWhenPresent
-
isTrue
-
isFalse
-
isLikeCaseInsensitive
-
isLikeCaseInsensitive
-
isLikeCaseInsensitiveWhenPresent
-
isLikeCaseInsensitiveWhenPresent
-
isNotLikeCaseInsensitive
-
isNotLikeCaseInsensitive
-
isNotLikeCaseInsensitiveWhenPresent
-
isNotLikeCaseInsensitiveWhenPresent
-
isInCaseInsensitive
-
isInCaseInsensitive
-
isInCaseInsensitiveWhenPresent
-
isInCaseInsensitiveWhenPresent
-
isNotInCaseInsensitive
-
isNotInCaseInsensitive
-
isNotInCaseInsensitiveWhenPresent
-
isNotInCaseInsensitiveWhenPresent
static IsNotInCaseInsensitiveWhenPresent isNotInCaseInsensitiveWhenPresent(Collection<String> values) -
sortColumn
Creates a sort specification based on a String. This is useful when a column has been aliased in the select list. For example:select(foo.as("bar")) .from(baz) .orderBy(sortColumn("bar"))
- Parameters:
name
- the string to use as a sort specification- Returns:
- a sort specification
-
sortColumn
Creates a sort specification based on a column and a table alias. This can be useful in a join where the desired sort order is based on a column not in the select list. This will likely fail in union queries depending on database support.- Parameters:
tableAlias
- the table aliascolumn
- the column- Returns:
- a sort specification
-