org.babyfish.jimmer.sql.kt.KSqlClientExtensions.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql-kotlin Show documentation
Show all versions of jimmer-sql-kotlin Show documentation
A revolutionary ORM framework for both java and kotlin
package org.babyfish.jimmer.sql.kt
import org.babyfish.jimmer.sql.association.Association
import org.babyfish.jimmer.sql.kt.ast.expression.constant
import org.babyfish.jimmer.sql.kt.ast.query.KMutableRootQuery
import kotlin.reflect.KClass
import kotlin.reflect.KProperty1
fun KSqlClient.exists(
type: KClass,
block: KMutableRootQuery.() -> Unit = {}
): Boolean = queries.forEntity(type) {
block()
select(constant(1))
}.limit(1).execute().isNotEmpty()
fun KSqlClient.listExists(
prop: KProperty1>,
block: KMutableRootQuery>.() -> Unit
): Boolean = queries.forList(prop) {
block()
select(constant(1))
}.limit(1).execute().isNotEmpty()
fun KSqlClient.refExists(
prop: KProperty1,
block: KMutableRootQuery>.() -> Unit
): Boolean = queries.forReference(prop) {
block()
select(constant(1))
}.limit(1).execute().isNotEmpty()
© 2015 - 2024 Weber Informatics LLC | Privacy Policy