Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Initially we also had support for SpEL Expression parameters in query derivation but we decided to leave it out for now, since we had some concerns whether having SpEL expressions in user code is a good idea.

Configure SpEL expression as a bean

@Bean
Expression currentUserEmailAdress(){
	return new SpelExpressionParser().parseExpression("principal?.emailAddress");
}

Allow Expressions to be used as Parameters in repository query methods

List<BusinessObject> findByOwnerEmailAddress(Expression currentUserEmailAddress);

Useage example

...
@Autowired Expression currentUserEmailAdress;
...
public void someBusinessMethod(..){
   List<BusinessObject> businessObjects = repository.findByOwnerEmailAddress(currentUserEmailAddress);
}

Please let us know what you think about that as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.