Skip to content

Commit

Permalink
docs: support stream in spring data repository
Browse files Browse the repository at this point in the history
  • Loading branch information
shouwn committed Dec 17, 2024
1 parent 4c4ae8b commit 2f2835f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
30 changes: 20 additions & 10 deletions docs/en/jpql-with-kotlin-jdsl/spring-supports.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,33 @@ If you declare your `JpqlSerializer` or `JpqlIntrospector` as a bean, it will be
If your `JpaRepository` extends `KotlinJdslJpqlExecutor`, you can use the extension provided by Kotlin JDSL.

```kotlin
interface AuthorRepository : JpaRepository<Author, Long>, KotlinJdslJpqlExecutor
interface BookRepository : JpaRepository<Book, Isbn>, KotlinJdslJpqlExecutor

authorRepository.findAll {
val result: List<Isbn?> = bookRepository.findAll {
select(
path(Author::authorId),
path(Book::isbn),
).from(
entity(Book::class),
)
}

val result: Page<Isbn?> = bookRepository.findPage(pageable) {
select(
path(Book::isbn),
).from(
entity(Author::class),
join(BookAuthor::class).on(path(Author::authorId).equal(path(BookAuthor::authorId))),
).groupBy(
path(Author::authorId),
).orderBy(
count(Author::authorId).desc(),
entity(Book::class),
)
}

val result: Slice<Isbn?> = bookRepository.findSlice(pageable) {
select(
path(Book::isbn),
).from(
entity(Book::class),
)
}

bookRepository.findPage(pageable) {
val result: Stream<Isbn?> = bookRepository.findStream {
select(
path(Book::isbn),
).from(
Expand Down
30 changes: 20 additions & 10 deletions docs/ko/jpql-with-kotlin-jdsl/spring-supports.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,33 @@ Kotlin JDSL은 Spring Boot AutoConfigure를 지원합니다.
만약 사용하고 있는 `JpaRepository``KotlinJdslJpqlExecutor`를 상속하면, Kotlin JDSL이 제공하는 확장 기능을 사용할 수 있습니다.

```kotlin
interface AuthorRepository : JpaRepository<Author, Long>, KotlinJdslJpqlExecutor
interface BookRepository : JpaRepository<Book, Isbn>, KotlinJdslJpqlExecutor

authorRepository.findAll {
val result: List<Isbn?> = bookRepository.findAll {
select(
path(Author::authorId),
path(Book::isbn),
).from(
entity(Book::class),
)
}

val result: Page<Isbn?> = bookRepository.findPage(pageable) {
select(
path(Book::isbn),
).from(
entity(Author::class),
join(BookAuthor::class).on(path(Author::authorId).equal(path(BookAuthor::authorId))),
).groupBy(
path(Author::authorId),
).orderBy(
count(Author::authorId).desc(),
entity(Book::class),
)
}

val result: Slice<Isbn?> = bookRepository.findSlice(pageable) {
select(
path(Book::isbn),
).from(
entity(Book::class),
)
}

bookRepository.findPage(pageable) {
val result: Stream<Isbn?> = bookRepository.findStream {
select(
path(Book::isbn),
).from(
Expand Down

0 comments on commit 2f2835f

Please sign in to comment.