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

org.babyfish.jimmer.spring.repository.KConfigurableQueries.kt Maven / Gradle / Ivy

There is a newer version: 0.9.19
Show newest version
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)
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy