org.babyfish.jimmer.spring.repository.KConfigurableQueries.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-spring-boot-starter Show documentation
Show all versions of jimmer-spring-boot-starter Show documentation
A revolutionary ORM framework for both java and kotlin
package org.babyfish.jimmer.spring.repository
import org.babyfish.jimmer.spring.repository.support.SpringPageFactory
import org.babyfish.jimmer.spring.repository.support.Utils
import org.babyfish.jimmer.sql.kt.ast.query.KConfigurableRootQuery
import org.springframework.data.domain.Page
import org.springframework.data.domain.PageImpl
import org.springframework.data.domain.PageRequest
import org.springframework.data.domain.Pageable
import java.sql.Connection
fun KConfigurableRootQuery<*, E>.fetchSpringPage(
pageIndex: Int,
pageSize: Int,
con: Connection? = null
): Page =
fetchPage(
pageIndex,
pageSize,
con,
SpringPageFactory.getInstance()
)
fun KConfigurableRootQuery<*, E>.fetchSpringPage(
pageable: Pageable?,
con: Connection? = null
): Page =
if (pageable === null || pageable.isUnpaged) {
fetchSpringPage(0, Int.MAX_VALUE, con)
} else {
fetchSpringPage(pageable.pageNumber, pageable.pageSize, con)
}