Skip to content

plgagnon2/ag-grid-builder-for-jpa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

ag-grid-builder-for-jpa

Usage

interface MyRepository : JpaRepository<T, UUID>, JpaSpecificationExecutor<T> {

...

@Service
class SomeService(
    private val someJpaRepository: MyRepository
) {
    fun fetch(request: ServerSideGetRowsRequest): SomeResponseDTO {
        val specifications = SpecificationBuilder.build<T>(request.filterModel)
        val sort = SortBuilder.build(request.sortModel)
        val pageRequest = PageRequestBuilder.build(request.startRow, request.endRow, sort)

        if (pageRequest == null) {
            val results = someJpaRepository.findAll(specifications, sort)
            return SomeResponseDTO(
                rowData = results,
                rowCount = results.size.toLong()
            )
        }

        val pagedResults = someJpaRepository.findAll(specifications, pageRequest)
        return SomeResponseDTO(
            rowData = pagedResults.content,
            rowCount = pagedResults.totalElements
        )
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages