我试图使用Spring-El传递多个In Clause参数,我的查询是:
@Query(nativeQuery = true, value = "select a.* from ACC a where (a.iban, a.currency) in (:#{#ibanAccounts.accountNumber} , :#{#ibanAccounts.currency})")
List<ACC> getAccount(@Param("ibanAccounts") List<AccountDetails> ibanAccounts);
但我收到了以下错误:
EL1008E:(pos 14): Property or field 'accountNumber' cannot be found on object of type 'java.util.ArrayList$SubList' - maybe not public?
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 14): Property or field 'accountNumber' cannot be found on object of type 'java.util.ArrayList$SubList' - maybe not public?
at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94)
at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:46)
at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:374)
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88)
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131)
在AccountDetails中,该字段与public getter一起出现。
任何人都可以指导我说错了吗?
答案 0 :(得分:0)
我相信你要找的是collection projection。
所以你需要使用这样的东西
@Query(nativeQuery = true, value = "select a.* from ACC a where (a.iban, a.currency) in :#{#ibanAccounts.![accountNumber]} , :#{#ibanAccounts.currency})")
List<ACC> getAccount(@Param("ibanAccounts") List<AccountDetails> ibanAccounts);