Why doesn't this stream & lambda expression work with SpEL declaration?

Spring Expression Language is defined in the developer guide. What you're trying to do isn't supported by the language at the moment. I'd also argue that this is a very weird place to put such code: an isolated method that you can unit test is much better indeed.


You can accomplish your intention with the following syntax (using Collection Selection and 'this')

here #root is your entity, and inside the selection, #this refers to a tag.

Example anyMatch:

"#root.getTags().?[#this.getId() == null].size() > 0"

Example allMatch:

"#root.getTags().?[#this.getId() == null].size() eq #root.getTags().size()"