运行条件更新查询,但收到错误无法解析给定参数参考的绑定

时间:2019-04-10 08:11:12

标签: jpa

我要运行查询以进行更新

更新 sensor_mediation_status 设置(sensor_ip,DESKTOP-5KM9TE2), 设置(last_item,890343480932434390) 哪里 table = audio;

entityTransaction.begin();  

                CriteriaUpdate<SensorMediationStatus> update = criteria.createCriteriaUpdate(SensorMediationStatus.class);

                Root<SensorMediationStatus> from1 = update.from(SensorMediationStatus.class);

                ParameterExpression<String> table = criteria.parameter(String.class);
                update.set("last_item", lastItem.get(0));
                update.set("sensor_ip",lastip.get(0));

                        update.where(criteria.equal(from1.get("table"),table));
                entityManager.createQuery(update).setParameter(table, "audio").executeUpdate();
                    entityTransaction.commit();```

1 个答案:

答案 0 :(得分:0)

将名称分配给ParameterExpression应该可以解决问题:

ParameterExpression<String> table = criteria.parameter(String.class, "tableParam");