All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.exposed.dao.View.kt Maven / Gradle / Ivy

There is a newer version: 0.56.0
Show newest version
package org.jetbrains.exposed.dao

import org.jetbrains.exposed.sql.Expression
import org.jetbrains.exposed.sql.Op
import org.jetbrains.exposed.sql.SizedIterable
import org.jetbrains.exposed.sql.SortOrder
import org.jetbrains.exposed.sql.vendors.ForUpdateOption
import kotlin.reflect.KProperty

/**
 * A [SizedIterable] of [Entity] instances that represent a subset of all managed entities that conform to the
 * provided [op] conditional expression.
 *
 * @param op The conditional expression to use when querying for matching entities.
 * @param factory The [EntityClass] to use when searching for matching entities.
 */
class View> (val op: Op, val factory: EntityClass<*, Target>) : SizedIterable {
    @Deprecated(
        "This function will be removed in future releases.",
        ReplaceWith("limit(n).offset(offset)"),
        DeprecationLevel.WARNING
    )
    override fun limit(n: Int, offset: Long): SizedIterable = factory.find(op).limit(n).offset(offset)
    override fun limit(count: Int): SizedIterable = factory.find(op).limit(count)
    override fun offset(start: Long): SizedIterable = factory.find(op).offset(start)
    override fun count(): Long = factory.find(op).count()
    override fun empty(): Boolean = factory.find(op).empty()
    override fun forUpdate(option: ForUpdateOption): SizedIterable = factory.find(op).forUpdate(option)
    override fun notForUpdate(): SizedIterable = factory.find(op).notForUpdate()

    override operator fun iterator(): Iterator = factory.find(op).iterator()
    operator fun getValue(o: Any?, desc: KProperty<*>): SizedIterable = factory.find(op)
    override fun copy(): SizedIterable = View(op, factory)
    override fun orderBy(vararg order: Pair, SortOrder>): SizedIterable = factory.find(op).orderBy(*order)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy