Skip to content

Using @DocumentReference throws ConverterNotFoundException during constructor creation #3806

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

Closed
oooplz opened this issue Sep 8, 2021 · 1 comment
Assignees
Labels
in: references DBRef and @DocumentReference type: bug A general bug

Comments

@oooplz
Copy link

oooplz commented Sep 8, 2021

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]
@christophstrobl christophstrobl self-assigned this Sep 8, 2021
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 8, 2021
@christophstrobl
Copy link
Member

Thanks for reporting - we'll look into it.

@christophstrobl christophstrobl added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 8, 2021
@mp911de mp911de closed this as completed in 9158be9 Sep 8, 2021
mp911de added a commit that referenced this issue Sep 8, 2021
Tweak reference documentation wording. Extract self/target source dereferencing into utility methods.

See: #3806
Original pull request: #3810.
@mp911de mp911de reopened this Sep 8, 2021
@mp911de mp911de added this to the 3.3 M3 (2021.1.0) milestone Sep 8, 2021
@mp911de mp911de changed the title Using @DocumentReference will throw org.springframework.core.convert.ConverterNotFoundException Using @DocumentReference throws ConverterNotFoundException during constructor creation Sep 8, 2021
@mp911de mp911de closed this as completed in f128e6d Sep 8, 2021
@mp911de mp911de added the in: references DBRef and @DocumentReference label Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: references DBRef and @DocumentReference type: bug A general bug
Projects
None yet
4 participants