Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support limit in spring data repository #764

Merged
merged 2 commits into from
Sep 3, 2024

Conversation

shouwn
Copy link
Member

@shouwn shouwn commented Aug 30, 2024

Motivation

  • Spring Data supports a Limit class as a parameter in Repository since version 3.2.
  • However, the Kotlin JDSL takes Spring Boot 2.7.9 and 3.0.3 as the minimum compatible version, which makes it difficult to support the Limit class.

Modifications

  • Add the parameters offset: Int, limit: Int to make Limit available in the Repository even for the minimum compatible Spring Boot version supported by the Kotlin JDSL.

Result

  • Users will be able to use offset and limit when using the findAll method of the KotlinJdslJpqlExecutor interface.
bookRepository.findAll(limit = 1) {
    select(
        path(Book::isbn),
    ).from(
        entity(Book::class),
        join(entity(BookPublisher::class)).on(path(BookPublisher::book).eq(entity(Book::class))),
    ).where(
        path(BookPublisher::publisherId).eq(3),
    )
}

bookRepository.findAll(offset = 1, limit = 1) {
    select(
        path(Book::isbn),
    ).from(
        entity(Book::class),
        join(entity(BookPublisher::class)).on(path(BookPublisher::book).eq(entity(Book::class))),
    ).where(
        path(BookPublisher::publisherId).eq(3),
    )
}

@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 8 lines in your changes missing coverage. Please review.

Project coverage is 91.73%. Comparing base (025f6c1) to head (e65f28c).

Files with missing lines Patch % Lines
...ata/jpa/javax/repository/KotlinJdslJpqlExecutor.kt 33.33% 4 Missing ⚠️
...ring/data/jpa/repository/KotlinJdslJpqlExecutor.kt 33.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #764      +/-   ##
==========================================
- Coverage   91.96%   91.73%   -0.24%     
==========================================
  Files         335      337       +2     
  Lines        3449     3447       -2     
  Branches      205      209       +4     
==========================================
- Hits         3172     3162      -10     
- Misses        215      223       +8     
  Partials       62       62              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

init: Jpql.() -> JpqlQueryable<SelectQuery<T>>,
): List<T?> {
return findAll(Jpql, init)
return findAll(Jpql, offset, limit, init)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both offset and limit are Integer types, so how about specifying the parameter names? I think it would be better to include them when calling the method, just like in the example you wrote. The rest of the code is the same.

--- korean
offset, limit 모두 Integer 타입인데 파라메터의 이름을 명시하는게 어떤가요? 예제로 적어놓으신 부분과 동일하게 메소드 호출시에도 넣어두는게 좋을 것 같습니다. 나머지 코드도 동일합니다.

@shouwn shouwn requested a review from cj848 September 3, 2024 06:07
@shouwn shouwn merged commit 6c3f67c into main Sep 3, 2024
4 checks passed
@shouwn shouwn deleted the hotfix/support-limit-in-repository branch September 3, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants