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

DATAJDBC-397 - Experimental support for SpEL inside @Query annotations.

Open schakko opened this issue 5 years ago • 1 comments

This PR tries to add experimental support to Spring Data JDBC. I've been able to use this PR with Spring Security, As described in https://spring.io/blog/2014/07/15/spel-support-in-spring-data-jpa-query-definitions you can now use something like

interface PersonRepository extends PagingAndSortingRepository<Person, String> {
  @Query("SELECT * FROM person WHERE username = :#{ principal?.username }")
  Person findActiveUser();	
}

Some things I like to discuss, because I don't want to do any stupid things here:

  • As I've already mentioned to @schauder on Twitter, this is a working prototype. I am pretty sure that there are too many corner cases I haven't think of or parts I am still lacking the understanding of :-(
  • Please let me know if I am misinterpreting the Contribution guidelines regarding the JavaDoc @author tag; I don't want to take credit for something I haven't contributed for.
  • ParameterBindings and ParameterBindingParser come from the Spring Data JPA project. At the moment they are both copy&pasted from SD-JPA and have public access modifiers. Both classes should probably be moved to Spring Data Commons.

Thank you for taking the time to look into this PR!

schakko avatar Jun 12 '20 06:06 schakko

Would really like to see SpEL support on Query-annotation here. Can this PR be finalized as is ?

dling avatar Jan 21 '21 23:01 dling

I rebased this, applied Marks comments and merged it with main. Thanks for this PR.

schauder avatar Sep 30 '22 11:09 schauder

@schauder This change is in which version? 3.0.1?

peteraramaldes avatar Feb 13 '23 13:02 peteraramaldes

@peteraramaldes This went into 3.0.0-RC1. It is therefore part of all 3.x releases after that including the 3.0.0 GA release.

schauder avatar Feb 13 '23 13:02 schauder