Closed
Description
version: spring-data-mongodb-3.3.0-M2
There is demo code below.
@Document
data class User(
@Id
var id: ObjectId? = null,
var username: String,
)
@Document
data class Post(
@Id
var id: ObjectId? = null,
var title: String,
var content: String?,
@DocumentReference
var author: User? = null
)
val user = mongoTemplate.save(User(null, "username0"))
val post = mongoTemplate.save(Post(null, "title0", "content0", user))
mongoTemplate.findById<Post>(post.id!!)
Exceptions is in here.
No converter found capable of converting from type [org.bson.types.ObjectId] to type [com.demo.User]
org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.bson.types.ObjectId] to type [com.demo.User]