spring-data-commons icon indicating copy to clipboard operation
spring-data-commons copied to clipboard

Add an ability to resolve property placeholders in BasicPersistentEntity

Open timsazon opened this issue 3 years ago • 5 comments

It'd be nice to have the ability to resolve placeholders in the entity values.

It can be done by adding PropertyResolver to the entity class.

timsazon avatar May 06 '21 15:05 timsazon

Can we take a step back first to understand what you're trying to achieve? Specifically, in Spring Data KeyValue we have support for SpEL expressions that are much more powerful than property resolution.

mp911de avatar May 10 '21 14:05 mp911de

I want to use application properties placeholders in @KeySpace and @RedisHash annotations, but afaik SpEL expressions can't handle it. For example, @EnableRedisWebSession annotation from Spring Session Data Redis supports such placeholders for namespaces. You can see a use case in the test: https://github.com/spring-projects/spring-data-keyvalue/pull/375/files#diff-3894631e2abde2a85bfbe3ff79c5eb88c4388932ad2d25907cf0f02d8bf6cbc6R70

timsazon avatar May 10 '21 22:05 timsazon

Take a look at this example. It's built on top of Spring Data KeyValue and by providing an EvaluationContextExtension you can expose properties that can be resolved/accessed already.

mp911de avatar May 11 '21 06:05 mp911de

In that case, it will require additional configuration. I think it'd be better to support this the same way as @Value or @EnableRedisWebSession do (it doesn't change API anyway).

timsazon avatar May 11 '21 08:05 timsazon

We decided to postpone the change for now.

mp911de avatar Jul 20 '21 09:07 mp911de

We've been revisiting this issue. The intermitted solution using an EvaluationContextExtension does however not provide an approach we'd like to follow when implementing property placeholder support. The placeholder evaluation should not be tied to any SpEL parsing/evaluation.

Currently we plan to investigate the possibility of extending existing components, like the MappingContext, so they are PropertySource aware an provide facilities for placeholder and potential SpEL resolution.

christophstrobl avatar Nov 22 '23 15:11 christophstrobl