Skip to content
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

Support redis specific repository. #2816

Open
junghoon-vans opened this issue Dec 28, 2023 · 3 comments · May be fixed by #2817
Open

Support redis specific repository. #2816

junghoon-vans opened this issue Dec 28, 2023 · 3 comments · May be fixed by #2817
Labels
type: enhancement A general enhancement

Comments

@junghoon-vans
Copy link
Contributor

junghoon-vans commented Dec 28, 2023

Previously, we were only specifying KeyValueRepository as the IdentifyingTypes of the repository.
This can be problematic when used with another implementation of KeyValueRepository,
so we need to provide a Redis-specific repository interface.

For example, if you have an implementation of a KeyValue named AnotherKV, as shown below,
Spring Data will not be able to determine which datastore it should run to.

interface MyRedisRepository extends KeyValueRepository<User, Long> { }
interface MyAnotherKVRepository extends KeyValueRepository<User, Long> { }

If Redis-specific repositories were added, this confusion could be eliminated.

interface MyRedisRepository extends RedisRepository<User, Long> { } // This always works with Redis.

By providing a module-specific repository, we can ensure that the repository is bound to a redis.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 28, 2023
@junghoon-vans junghoon-vans linked a pull request Dec 28, 2023 that will close this issue
4 tasks
@junghoon-vans junghoon-vans changed the title Support module specific repository. Support redis specific repository. Dec 28, 2023
@mp911de
Copy link
Member

mp911de commented Dec 28, 2023

This is by design to avoid having another empty store-specific interface.
Repository disambiguation works also through annotations on the domain type. If you add @RedisHash to your entity, you can leverage disambiguation.

Let me know how this goes.

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Dec 28, 2023
@junghoon-vans
Copy link
Contributor Author

Of course, as you say, there is a way to use annotations, but according to the reference documentation, a module-based repository should also be provided.

However, in the current implementation, there is no repository interface that is specific to Redis, so there are limited ways to utilize a module-based repository.

So I created a mark interface that is simply an extension of KeyValueRepository. This interface is only utilized by Redis, so it is clearly distinguishable from other repositories.

@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 Dec 29, 2023
@mp911de
Copy link
Member

mp911de commented Dec 29, 2023

Over time, we've realized that introducing module-specific interface types are a harm to the desired programming model. Again, introducing empty marker interfaces do not improve such arrangements but they introduce technology-specific dependencies whereas Spring Data aims to create a store-independent experience in which calling code shouldn't be aware of the technology-specifics.

@mp911de mp911de added the for: team-attention An issue we need to discuss as a team to make progress label Dec 29, 2023
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged for: team-attention An issue we need to discuss as a team to make progress status: feedback-provided Feedback has been provided labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants