I am trying to use size
property on List using Spring EL, which's throwing exception that size can't be found.
@Cacheable(value = "cache", unless = "#result.size > 0")
public List<Results> getResult();
Exception:
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 8): Field or property 'size' cannot be found on object of type 'java.util.ArrayList'
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:217)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:85)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:43)
at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:346)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:84)
size
resolves to List#getSize()
which doesn't exist. Try with size()
as follows:
@Cacheable(value = "cache", unless = "#result.size() > 0")
public List<Results> getResult();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With