Skip to content

Not able to override keyValueMappingContext #637

@berickus

Description

@berickus

Due to the fact that the RedisEnhancedMappingContext is set as @primary, even when having your own RedisMappingContext like it is done in the unit test, it is not respected and a custom key space resolver is never used.

My config and bean which is never used.
`@Configuration
public class RedisKeyspaceConfig {

@Bean
public RedisMappingContext customKeyValueMappingContext(@Qualifier("redisEnhancedMappingContext") RedisMappingContext mappingContext,
                                                  RedisConfigProperties config,
                                                  Tenant tenant) {
    mappingContext.setKeySpaceResolver(type -> RedisUtils.getKeyspace(type, config, tenant.getName()));
    return mappingContext;
}

}`

Also this way it does not work:
`@Configuration
public class RedisKeyspaceConfig {

@Bean
public RedisMappingContext customKeyValueMappingContext(RedisConfigProperties config,
                                                  Tenant tenant) {
    RedisEnhancedMappingContext mappingContext = new RedisEnhancedMappingContext();
    mappingContext.setKeySpaceResolver(type -> RedisUtils.getKeyspace(type, config, tenant.getName()));
    return mappingContext;
}

}`

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingv1.0.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions