【spring data jpa】jpa中使用in查询或删除 在@Query中怎么写 ,报错:org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'goodsConfigUid' cannot be found on null 怎么处理

时间:2023-03-08 20:40:14
【spring data jpa】jpa中使用in查询或删除 在@Query中怎么写 ,报错:org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'goodsConfigUid' cannot be found on null 怎么处理

示例代码如下:

@Modifying
@Transactional
@Query("delete from GoodsBindConfigMapping gbc " +
"where gbc.goodsConfigUid = :#{#bean.goodsConfigUid} " +
"and gbc.tenementId = :#{#bean.tenementId} " +
"and gbc.goodConfigFlag = :#{#bean.goodConfigFlag} "+
"and gbc.goodTypeUid in (:#{#bean.goodsList})")
int deleteByConfigUidAndTypeUid(@Param("bean") BindConfigBean bean);

报错:

org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'goodsConfigUid' cannot be found on null

解决方法:

是因为在使用@Query写语句的时候,没有使用@Param()标明参数实体