Skip to content

Support automatic registration of converters #4181

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

Conversation

sangyongchoi
Copy link
Contributor

Hi, i am spring-data-mongo user.
I had some inconvenience when registered converters.
Is currently manually register converters.

@Bean
fun mongoCustomConversions(): MongoCustomConversions {
    val converters = applicationContext.getBeansOfType(Converter::class.java).values
        .stream().collect(Collectors.toList())
    return MongoCustomConversions(converters)
}

Can I change to automatic registration from manually registration ?
If it's not possible, can you tell me why?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 25, 2022
@mp911de
Copy link
Member

mp911de commented Sep 26, 2022

How is that supposed to work if a user has multiple Spring Data modules on the class path. We would register all converters in all modules without having a way to distinguish whether a Converter is intended for Spring Data usage and for which module it should be used.

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Sep 26, 2022
@sangyongchoi
Copy link
Contributor Author

sangyongchoi commented Sep 26, 2022

How is that supposed to work if a user has multiple Spring Data modules on the class path. We would register all converters in all modules without having a way to distinguish whether a Converter is intended for Spring Data usage and for which module it should be used.

@mp911de
Thank you for reply 😄
So i hope add interface (e.g DocumentFieldConverter).

interface DocumentFieldConverter<S, T> : Converter<S, T>

Then, this is possible as follows.

if (listableBeanFactory != null) {
	converters = listableBeanFactory
			.getBeansOfType(DocumentFieldConverter.class)
			.values()
			.stream()
			.toList();
} else {
	converters = Collections.emptyList();
}

Is this possible?

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 26, 2022
@mp911de
Copy link
Member

mp911de commented Oct 18, 2022

Thanks for your suggestion. We want to keep the existing mechanism and keep the converter registration as simple as possible. If adding an interface to your converters works in your project, then we encourage you to follow that path and apply that pattern in your project.

@mp911de mp911de closed this Oct 18, 2022
@mp911de mp911de added status: declined A suggestion or change that we don't feel we should currently apply and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Oct 18, 2022
christophstrobl pushed a commit that referenced this pull request Apr 14, 2025
Supports range style queries for encrypted fields

Closes: #4181
Original Pull Request: #4885
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants