Spring @Cache アノテーションで Java 8 ストリームとラムダ式を使用しようとしています。
私は以下を使用しようとしています:
@CacheEvict(value = "tags", allEntries = true,
condition = "#entity.getTags().stream().anyMatch(tag -> tag.getId() == null)")
それは失敗しています:
SEVERE: The RuntimeException could not be mapped to a response, re-throwing to the HTTP container
org.springframework.expression.spel.SpelParseException:
EL1042E:(pos 40): Problem parsing right operand
ただし、ストリームをエンティティのメソッドに移動すると、動作させることができます。注釈は、エラーなしで次のように機能します。
@CacheEvict(value = "tags", beforeInvocation=true, allEntries = true,
condition = "#entity.containsNewTag()")
「containtsNewTag()」メソッドを必要とせず、可能であれば SpEL 式でストリームを直接使用したいと考えています。これはできますか?