Skip to content

Commit

Permalink
Merge pull request #788 from pot-mot/feat-kt-rootQuery-exist
Browse files Browse the repository at this point in the history
Add KConfigurableRootQuery exists function
  • Loading branch information
babyfish-ct authored Nov 17, 2024
2 parents 2569f74 + bea56d9 commit 4d19ae1
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import org.babyfish.jimmer.lang.NewChain
import org.babyfish.jimmer.sql.ast.query.PageFactory
import org.babyfish.jimmer.sql.kt.ast.expression.rowCount
import java.sql.Connection
import org.babyfish.jimmer.sql.kt.ast.expression.constant

interface KConfigurableRootQuery<E: Any, R> : KTypedRootQuery<R> {

Expand All @@ -26,6 +27,11 @@ interface KConfigurableRootQuery<E: Any, R> : KTypedRootQuery<R> {
.withoutSortingAndPaging()
.execute(con)[0]

fun exists(con: Connection? = null): Boolean =
limit(1)
.reselect { select(constant(1)) }
.execute(con).isNotEmpty()

fun <P: Any> fetchPage(
pageIndex: Int,
pageSize: Int,
Expand Down

0 comments on commit 4d19ae1

Please sign in to comment.