【spring data jpa】jpa中使用in查询或删除 在@Query中怎么写 ,报错:org.springframework.expression.spel.SpelEvaluationExc...

本文介绍了一个关于Spring Data JPA中使用@Query注解时出现的错误案例,具体错误为找不到属性'goodsConfigUid',并详细解释了如何通过正确使用@Param注解来解决这个问题。

示例代码如下:

@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()标明参数实体

"EL1008E: Property or field 'creNo_' cannot be found on object of type 'com.joyintech.entity.cust.CustInfo' - maybe not public or not valid?[org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:223), org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:106), org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:53), org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:412), org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:93), org.springframework.expression.spel.ast.OpPlus.getValueInternal(OpPlus.java:95), org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:114), org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:273), org.springframework.cache.interceptor.CacheOperationExpressionEvaluator.key(CacheOperationExpressionEvaluator.java:104), org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.generateKey(CacheAspectSupport.java:795), org.springframework.cache.interceptor.CacheAspectSupport.generateKey(CacheAspectSupport.java:591), org.springframework.cache.interceptor.CacheAspectSupport.performCacheEvict(CacheAspectSupport.java:508), org.springframework.cache.interceptor.CacheAspectSupport.processCacheEvicts(CacheAspectSupport.java:492), org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:433), org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:345), org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:64), org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186), org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAo
最新发布
08-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值