-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Insufficient documentation for Value expressions #3688
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
Comments
Usage of Config Properties is documented at https://docs.spring.io/spring-data/jpa/reference/jpa/query-methods.html#jpa.query.spel-expressions at Let me know what else you're looking for. For JPA, the evaluation of annotation values is subject to JPA providers, where we cannot inject additional functionality. However, the mentioned page about Value Expressions is part of our common documentation. Maybe the issue is that we created some over-expectation by our naming. Value Expressions are SpEL expressions plus Property Placeholders whereas we previously only supported SpEL expressions. |
This section misses two important topics.
But if I try to use it in @query annotation (productService is bean id):
then I receive an exception: So it's not clear whether we can access bean properties/methods in Value Expressions and if yes then how? |
Documenting the scope makes sense. For the second issue, it works as designed. It would make sense to call out that the default root object is the array of query method parameters when working with queries. Any beans must be accessed via By explaining scopes in the docs, we can make the second case more clear. |
Unfortunately your advise didn't help. I added #:
But now error is different:
Although productService bean is available in the application context. |
I investigated and debugged this issue and it seems that it's not possible to access Spring beans using this construction:
There's BeanResolver interface which JavaDocs clearly state that @ or & characters should be used instead of #:
So the correct construction is
|
Apologies, you're right with |
The docs are updated and snapshot variants are available from https://docs.spring.io/spring-data/jpa/reference/3.4-SNAPSHOT/jpa/value-expressions.html. Spring Data docs isn't the place to explain the syntax (i.e. accessing beans and other invariants), Spring Framework has a reference documentation and we've updated our links. That being said, I consider this ticket done. |
Spring Data 3.4.0 brings new feature - Value Expressions (#3619)
However the latest documentation section(https://docs.spring.io/spring-data/jpa/reference/jpa/value-expressions.html) has only one example of the code:
This example is from Spring Data Mongo and can't be used for Spring Data JPA. Moreover the whole section is copied from Spring Data Mongo documentation without any changes (https://docs.spring.io/spring-data/mongodb/reference/mongodb/value-expressions.html)
So neither the documentation nor GitHub ticket have examples how to use new feature in Spring Data JPA. So it'd be nice to add few examples in the documentation.
The text was updated successfully, but these errors were encountered: