dany giguere
02/12/2024, 10:39 PMdata class UserDto(
val id: Long?,
...
var posts: List<PostDto>? = emptyList()
)
and my post:
data class PostDto(
val id: Long?,
var userId: Long,
...
var user: UserDto? = null
)
my function was going to be this:
suspend fun findByIdWithUser(id: Long): PostDto? = coroutineScope {
val post = async{findById(id)}
val user = async{userRepository.findById(id)}
return@coroutineScope post.await()?.copy(user = user.await())
}
But it won’t compile because I get this error: Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.
Ideas anyone ?Jacob
02/12/2024, 11:32 PMJohan
02/13/2024, 1:23 AMdany giguere
02/13/2024, 3:47 PM