Skip to content
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

@Query definitions with SpEL expressions #164

Closed
a8t3r opened this issue Aug 19, 2019 · 1 comment
Closed

@Query definitions with SpEL expressions #164

a8t3r opened this issue Aug 19, 2019 · 1 comment
Labels
type: enhancement A general enhancement

Comments

@a8t3r
Copy link

a8t3r commented Aug 19, 2019

Something like that https://spring.io/blog/2014/07/15/spel-support-in-spring-data-jpa-query-definitions:

@Query("select u from User u where u.firstname = :#{#customer.firstname}")
List<User> findUsersByCustomersFirstname(@Param("customer") Customer customer);

I thought this feature is common to all spring data projects, but it seems to be specific to jpa.

@mp911de mp911de added the type: enhancement A general enhancement label Sep 2, 2019
@mp911de mp911de added this to the General Backlog milestone Sep 2, 2019
@wixanz
Copy link

wixanz commented Dec 20, 2019

Any news when SpEL expressions will be supported?

mp911de added a commit that referenced this issue Feb 20, 2020
We now support SpEL expressions in string-based queries to bind parameters for more dynamic queries. SpEL expressions are enclosed in :#{…} and rendered as synthetic named parameter so their values are substituted with bound parameters to avoid SQL injection attach vectors.

interface PersonRepository extends Repository<Person, String> {

	@query("SELECT * FROM person WHERE lastname = :#{'hello'}")
	Mono<Person> findHello();

	@query("SELECT * FROM person WHERE lastname = :#{[0]} and firstname = :firstname")
	Mono<Person> findByLastnameAndFirstname(@param("value") String value, @param("firstname") String firstname);

	@query("SELECT * FROM person WHERE lastname = :#{#person.name}")
	Mono<Person> findByExample(@param("person") Person person);
}
@mp911de mp911de closed this as completed Feb 20, 2020
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

3 participants