Package org.ktorm.dsl
Constructs strong-typed SQL DSL.
Types
Name | Summary |
---|---|
object AliasRemover : SqlExpressionVisitorInterceptor Expression visitor interceptor for removing table aliases, used by Ktorm internally. | |
open class AssignmentsBuilder Base class of DSL builders, provide basic functions used to build assignments for insert or update DSL. | |
class BatchInsertStatementBuilder<T : BaseTable<*>> DSL builder for batch insert statements. | |
class BatchUpdateStatementBuilder<T : BaseTable<*>> DSL builder for batch update statements. | |
Helper class used to build case-when SQL DSL. See CaseWhenExpression. | |
class Query Query is an abstraction of query operations and the core class of Ktorm’s query DSL. | |
class QueryRowSet : CachedRowSet Special implementation of ResultSet, used to hold the Query results for Ktorm. | |
data class QuerySource Represents a query source, used in the | |
class UpdateStatementBuilder : AssignmentsBuilder DSL builder for update statements. | |
Return type for WHEN function, call its extension function THEN to finish a SQL when clause. | |
object WindowFrames Utility object that creates expressions of window frame bounds. |
Annotations
Name | Summary |
---|---|
annotation class KtormDsl Marker annotation for Ktorm DSL builder classes. |
Extensions for External Classes
Name | Summary |
---|---|
Functions
Name | Summary |
---|---|
infix fun ColumnDeclaring<Boolean>.and( infix fun ColumnDeclaring<Boolean>.and( And operator, translated to the | |
fun ColumnDeclaring<*>.asc(): OrderByExpression Order this column or expression in ascending order. | |
fun Query.asIterable(): Iterable<QueryRowSet> Wrap this query as Iterable. | |
Return a Map containing key-value pairs provided by transform function applied to rows of the query. | |
fun <K, V> Query.associateBy( Return a Map containing the values provided by valueTransform and indexed by keySelector functions applied to | |
fun <K, V, M : MutableMap<in K, in V>> Query.associateByTo( Populate and return the destination mutable map with key-value pairs, where key is provided by the keySelector | |
fun <K, V, M : MutableMap<in K, in V>> Query.associateTo( Populate and return the destination mutable map with key-value pairs provided by transform function applied to | |
fun <C : Number> avg( The avg function, translated to | |
fun <C : Number> avgDistinct( The avg function with distinct, translated to | |
fun <T : BaseTable<*>> Database.batchInsert( Construct insert expressions in the given closure, then batch execute them and return the effected | |
fun <T : BaseTable<*>> Database.batchUpdate( Construct update expressions in the given closure, then batch execute them and return the effected | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.between( Between operator, translated to | |
Starts a searched case-when DSL. Starts a simple case-when DSL with the given operand. | |
fun <T : Any> ColumnDeclaring<*>.cast( Cast the current column or expression to the given SqlType. | |
fun count( The count function, translated to | |
fun countDistinct( The count function with distinct, translated to | |
fun QuerySource.crossJoin( Perform a cross join and return a new QuerySource, translated to | |
fun cumeDist(): WindowFunctionExpression<Double> The cume_dist window function, translated to | |
Delete the records in the table that matches the given predicate. | |
Delete all the records in the table. | |
fun denseRank(): WindowFunctionExpression<Int> The dense_rank window function, translated to | |
fun ColumnDeclaring<*>.desc(): OrderByExpression Order this column or expression in descending order, corresponding to the | |
infix operator fun <T : Number> ColumnDeclaring<T>.div( infix operator fun <T : Number> ColumnDeclaring<T>.div( infix operator fun <T : Number> T.div( Divide operator, translated to | |
fun <T : Any, R : Any> CaseWhen<T, R>.ELSE( Specifies the else clause for the case-when DSL. | |
fun <R : Any> CaseWhen<*, R>.END(): CaseWhenExpression<R> Finishes the case-when DSL and returns a CaseWhenExpression. | |
infix fun <T : Any> ColumnDeclaring<T>.eq( infix fun <T : Any> ColumnDeclaring<T>.eq( infix fun <T : Any> T.eq( Equal operator, translated to | |
fun exists(query: Query): ExistsExpression Check if the given query has at least one result, translated to the | |
fun <T : Any> firstValue( The first_value window function, translated to | |
Return a single list of all elements yielded from results of transform function being invoked on each row | |
Return a single list of all elements yielded from results of transform function being invoked on each row | |
fun <R, C : MutableCollection<in R>> Query.flatMapIndexedTo( Append all elements yielded from results of transform function being invoked on each row and its index | |
fun <R, C : MutableCollection<in R>> Query.flatMapTo( Append all elements yielded from results of transform function being invoked on each row of the query, | |
Accumulate value starting with initial value and applying operation to current accumulator value and each row. | |
Accumulate value starting with initial value and applying operation to current accumulator value and each row | |
fun Query.forEach(action: (row: QueryRowSet) -> Unit): Unit Perform the given action on each row of the query. | |
fun Query.forEachIndexed( Perform the given action on each row of the query, providing sequential index with the row. | |
fun Database.from(table: BaseTable<*>): QuerySource Wrap the specific table as a QuerySource. | |
fun QuerySource.fullJoin( Perform a full join and return a new QuerySource, translated to | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.greater( infix fun <T : Comparable<T>> ColumnDeclaring<T>.greater( infix fun <T : Comparable<T>> T.greater( Greater operator, translated to | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.greaterEq( infix fun <T : Comparable<T>> ColumnDeclaring<T>.greaterEq( infix fun <T : Comparable<T>> T.greaterEq( Greater-eq operator, translated to | |
fun Query.groupBy( fun Query.groupBy(vararg columns: ColumnDeclaring<*>): Query Specify the | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.gt( infix fun <T : Comparable<T>> ColumnDeclaring<T>.gt( infix fun <T : Comparable<T>> T.gt( Greater operator, translated to | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.gte( infix fun <T : Comparable<T>> ColumnDeclaring<T>.gte( infix fun <T : Comparable<T>> T.gte( Greater-eq operator, translated to | |
fun Query.having(condition: ColumnDeclaring<Boolean>): Query Specify the fun Query.having( Specify the | |
fun <T : Any> ColumnDeclaring<T>.inList( infix fun <T : Any> ColumnDeclaring<T>.inList( infix fun ColumnDeclaring<*>.inList( In-list operator, translated to the | |
fun QuerySource.innerJoin( Perform an inner join and return a new QuerySource, translated to | |
Construct an insert expression in the given closure, then execute it and return the effected row count. | |
fun <T : BaseTable<*>> Database.insertAndGenerateKey( Construct an insert expression in the given closure, then execute it and return the auto-generated key. | |
Insert the current Query‘s results into the given table, useful when transfer data from a table to another table. | |
fun ColumnDeclaring<*>.isNotNull(): UnaryExpression<Boolean> Check if the current column or expression is not null, translated to | |
fun ColumnDeclaring<*>.isNull(): UnaryExpression<Boolean> Check if the current column or expression is null, translated to | |
fun QuerySource.joinReferencesAndSelect(): Query Return a new-created Query object, left joining all the reference tables, and selecting all columns of them. | |
fun <A : Appendable> Query.joinTo( Append the string from all rows separated using separator and using the given prefix and postfix if supplied. | |
fun Query.joinToString( Create a string from all rows separated using separator and using the given prefix and postfix if supplied. | |
fun <T : Any> lag( fun <T : Any> lag( The lag window function, translated to | |
fun <T : Any> lastValue( The last_value window function, translated to | |
fun <T : Any> lead( fun <T : Any> lead( The lead window function, translated to | |
fun QuerySource.leftJoin( Perform a left join and return a new QuerySource, translated to | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.less( infix fun <T : Comparable<T>> ColumnDeclaring<T>.less( infix fun <T : Comparable<T>> T.less( Less operator, translated to | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.lessEq( infix fun <T : Comparable<T>> ColumnDeclaring<T>.lessEq( infix fun <T : Comparable<T>> T.lessEq( Less-eq operator, translated to | |
infix fun ColumnDeclaring<*>.like( infix fun ColumnDeclaring<*>.like( Like operator, translated to the | |
Specify the pagination limit parameter of this query. Specify the pagination parameters of this query. | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.lt( infix fun <T : Comparable<T>> ColumnDeclaring<T>.lt( infix fun <T : Comparable<T>> T.lt( Less operator, translated to | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.lte( infix fun <T : Comparable<T>> ColumnDeclaring<T>.lte( infix fun <T : Comparable<T>> T.lte( Less-eq operator, translated to | |
fun <R> Query.map( Return a list containing the results of applying the given transform function to each row of the query. | |
Return a list containing the results of applying the given transform function to each row and its index. | |
Return a list containing only the non-null results of applying the given transform function to each row | |
fun <R : Any, C : MutableCollection<in R>> Query.mapIndexedNotNullTo( Apply the given transform function to each row and its index and append only the non-null results to | |
fun <R, C : MutableCollection<in R>> Query.mapIndexedTo( Apply the given transform function to each row and its index and append the results to the given destination. | |
Return a list containing only the non-null results of applying the given transform function to each row of | |
fun <R : Any, C : MutableCollection<in R>> Query.mapNotNullTo( Apply the given transform function to each row of the query and append only the non-null results to | |
fun <R, C : MutableCollection<in R>> Query.mapTo( Apply the given transform function to each row of the query and append the results to the given destination. | |
fun <C : Comparable<C>> max( The max function, translated to | |
fun <C : Comparable<C>> maxDistinct( The max function with distinct, translated to | |
fun <C : Comparable<C>> min( The min function, translated to | |
fun <C : Comparable<C>> minDistinct( The min function with distinct, translated to | |
infix operator fun <T : Number> ColumnDeclaring<T>.minus( infix operator fun <T : Number> ColumnDeclaring<T>.minus( infix operator fun <T : Number> T.minus( Minus operator, translated to | |
infix fun <T : Any> ColumnDeclaring<T>.neq( infix fun <T : Any> ColumnDeclaring<T>.neq( infix fun <T : Any> T.neq( Not-equal operator, translated to | |
operator fun ColumnDeclaring<Boolean>.not(): UnaryExpression<Boolean> Negative operator, translated to the | |
infix fun <T : Comparable<T>> ColumnDeclaring<T>.notBetween( Not-between operator, translated to | |
infix fun <T : Any> ColumnDeclaring<T>.notEq( infix fun <T : Any> ColumnDeclaring<T>.notEq( infix fun <T : Any> T.notEq( Not-equal operator, translated to | |
fun notExists(query: Query): ExistsExpression Check if the given query doesn’t have any results, translated to the | |
fun <T : Any> ColumnDeclaring<T>.notInList( infix fun <T : Any> ColumnDeclaring<T>.notInList( infix fun ColumnDeclaring<*>.notInList( Not-in-list operator, translated to the | |
infix fun ColumnDeclaring<*>.notLike( infix fun ColumnDeclaring<*>.notLike( Not like operator, translated to the | |
fun <T : Any> nthValue( The nth_value window function, translated to | |
fun ntile(n: Int): WindowFunctionExpression<Int> The ntile window function, translated to | |
Specify the pagination offset parameter of this query. | |
infix fun ColumnDeclaring<Boolean>.or( infix fun ColumnDeclaring<Boolean>.or( Or operator, translated to the | |
fun Query.orderBy( fun Query.orderBy(vararg orders: OrderByExpression): Query Specify the fun WindowSpecificationExpression.orderBy( fun WindowSpecificationExpression.orderBy( Specify the order-by clause of this window using the given order-by expressions. | |
fun <T : Any> WindowFunctionExpression<T>.over( fun <T : Any> WindowFunctionExpression<T>.over( Specify the window specification for this window function. fun <T : Any> AggregateExpression<T>.over( fun <T : Any> AggregateExpression<T>.over( Use this aggregate function as a window function and specify its window specification. | |
fun WindowSpecificationExpression.partitionBy( fun WindowSpecificationExpression.partitionBy( Specify the partition-by clause of this window using the given columns or expressions. | |
fun percentRank(): WindowFunctionExpression<Double> The percent_rank window function, translated to | |
infix operator fun <T : Number> ColumnDeclaring<T>.plus( infix operator fun <T : Number> ColumnDeclaring<T>.plus( infix operator fun <T : Number> T.plus( Plus operator, translated to | |
fun WindowSpecificationExpression.range( Specify the frame clause of this window using the given bound in range unit. | |
fun WindowSpecificationExpression.rangeBetween( Specify the frame clause of this window using the given bounds (start & end) in rows unit. | |
fun rank(): WindowFunctionExpression<Int> The rank window function, translated to | |
infix operator fun <T : Number> ColumnDeclaring<T>.rem( infix operator fun <T : Number> ColumnDeclaring<T>.rem( infix operator fun <T : Number> T.rem( Mod operator, translated to | |
fun QuerySource.rightJoin( Perform a right join and return a new QuerySource, translated to | |
fun rowNumber(): WindowFunctionExpression<Int> The row_number window function, translated to | |
fun WindowSpecificationExpression.rows( Specify the frame clause of this window using the given bound in rows unit. | |
fun WindowSpecificationExpression.rowsBetween( Specify the frame clause of this window using the given bounds (start & end) in rows unit. | |
fun QuerySource.select( fun QuerySource.select( Create a query object, selecting the specific columns or expressions from this QuerySource. | |
fun QuerySource.selectDistinct( fun QuerySource.selectDistinct( Create a query object, selecting the specific columns or expressions from this QuerySource distinctly. | |
fun <C : Number> sum( The sum function, translated to | |
fun <C : Number> sumDistinct( The sum function with distinct, translated to | |
fun <T : Any, R : Any> WhenContinuation<T, Nothing>.THEN( fun <T : Any, R : Any> WhenContinuation<T, Nothing>.THEN( fun <T : Any, R : Any> WhenContinuation<T, R>.THEN( fun <T : Any, R : Any> WhenContinuation<T, R>.THEN( Finishes the current when clause with the given result. | |
infix operator fun <T : Number> ColumnDeclaring<T>.times( infix operator fun <T : Number> ColumnDeclaring<T>.times( infix operator fun <T : Number> T.times( Multiply operator, translated to | |
fun ColumnDeclaring<out Number>.toDouble(): CastingExpression<Double> Cast the current column or expression’s type to Double. | |
fun ColumnDeclaring<out Number>.toFloat(): CastingExpression<Float> Cast the current column or expression’s type to Float. | |
fun ColumnDeclaring<out Number>.toInt(): CastingExpression<Int> fun ColumnDeclaring<Boolean>. Cast the current column or expression’s type to Int. | |
fun ColumnDeclaring<out Number>.toLong(): CastingExpression<Long> Cast the current column or expression’s type to Long. | |
fun ColumnDeclaring<out Number>.toShort(): CastingExpression<Short> Cast the current column or expression’s type to Short. | |
operator fun <T : Number> ColumnDeclaring<T>.unaryMinus(): UnaryExpression<T> Unary minus operator, translated to | |
operator fun <T : Number> ColumnDeclaring<T>.unaryPlus(): UnaryExpression<T> Unary plus operator, translated to | |
Union this query with the given one, corresponding to the | |
Union this query with the given one, corresponding to the | |
Construct an update expression in the given closure, then execute it and return the effected row count. | |
fun <T : Any, R : Any> CaseWhen<T, R>.WHEN( fun <T : Any, R : Any> CaseWhen<T, R>.WHEN( Starts a when clause with the given condition. | |
fun Query.where(condition: ColumnDeclaring<Boolean>): Query Specify the fun Query.where( Specify the | |
fun Query.whereWithConditions( Create a mutable list, then add filter conditions to the list in the given callback function, finally combine | |
fun Query.whereWithOrConditions( Create a mutable list, then add filter conditions to the list in the given callback function, finally combine | |
fun window(): WindowSpecificationExpression Create a default window specification. | |
fun Query.withIndex(): Iterable<IndexedValue<QueryRowSet>> Return a lazy Iterable that wraps each row of the query into an IndexedValue containing the index of | |
infix fun ColumnDeclaring<Boolean>.xor( infix fun ColumnDeclaring<Boolean>.xor( Xor operator, translated to the |