https://kotlinlang.org logo
#spring
Title
# spring
k

kubele

02/28/2024, 2:24 PM
Hi, is there an example that uses r2dbc, CoroutineCrudRepository and ManyToOne/ManyToMany relationships?
🚫 1
j

Johan

02/28/2024, 2:57 PM
Of what I remember, it isn't supported yet
thank you color 1
d

dany giguere

02/29/2024, 10:49 PM
You could create your own manyToMany relationship (or anyone) by yourself using DataBase Client. And then you can even run queries in parallel. Look at this fully functional demo: https://github.com/danygiguere/spring-boot-3-reactive-with-kotlin-coroutines/blob/main/src/main/kotlin/com/example/demo/post/PostService.kt
Copy code
// oneToMany relationship query example
    suspend fun findByIdWithImages(id: Long): PostWithImagesDto? = coroutineScope {
        val post = async{findById(id)}
        val images = async{imageRepository.findByPostId(id)?.toList()}
        return@coroutineScope post.await()?.toPostWithImagesDto()?.copy(images = images.await())
    }
thank you color 1
5 Views