Skip to content

Provide API to detect SpEL expression in repository query strings [DATACMNS-1258] #1687

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

Closed
spring-projects-issues opened this issue Feb 12, 2018 · 1 comment
Assignees
Labels
type: enhancement A general enhancement

Comments

@spring-projects-issues
Copy link

Gerrit Meier opened DATACMNS-1258 and commented

To provide SpEL support to the users most of the Spring Data projects use their own logic to parse the given query, interpret SpEL expression, replace SpEL expressions with repository specific placeholders and create parameter mapping for them with the evaluated values.

At least the providing of common SpEL expressions (like :#{#...}, ?:#{[...}}, etc.) and evaluating them to a parameter map could be done by a functionality based in Spring Data Commons.
Besides the easier maintenance of parsing and evaluating it would define the "right" placeholders that are to be used in @Query values.
To generate the repository specific placeholders a supplier function or something similar would be required to enable the replacement mechanism to generate a valid query with placeholder


Issue Links:

  • DATACMNS-1260 Extract EvaluationContextProvider and SPIs into dedicated package
    ("depends on")
  • DATAGRAPH-839 @Query annotation should support SpEL
    ("is depended on by")
  • DATAJPA-1267 Integrate newly created API to detect SpEL expressions in repository queries
    ("is depended on by")

Referenced from: pull request #275

@spring-projects-issues
Copy link
Author

Jens Schauder commented

JPA supports currently the following styles of SpEL

  • :#{xxx} and ?#{xxx} (defined in StringQuery which mimic named and indexed parameters in NamedParameterJdbcTemplate, JPA, and plain JDBC, although the behavior is exactly the same. The expressions get replace by bind parameter which gets bound the evaluation result of the expression.
  • #{#entityName} this one works differently in that it does not create a bind parameter but is considered a template. i.e. the Spel Expression gets evaluated combined with the rest of the query to a new query.

xxx denotes the actual SpEL expression which might start with a # or contain just and array access like [0] thereby referencing parameters

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

No branches or pull requests

2 participants