spring-data-commons
spring-data-commons copied to clipboard
Add an ability to resolve property placeholders in BasicPersistentEntity
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.
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.
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
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.
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).
We decided to postpone the change for now.
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.