我正在使用Hibernate和Spring Data,我正在尝试使用SpEL以下列方式创建自定义合并查询:
<script type="text/javascript">
speechSynthesis.speak(new SpeechSynthesisUtterance(myString));
</script>
结果如下
@Modifying
@Query("UPDATE Order o SET o.serial = COALESCE(?#{#another.serial}, o.serial), " +
"o.owner = COALESCE(?#{#another.owner}, o.owner)")
Order nullSafeUpdate(@Param("another") Order another);
我已尝试根据这些guidelines将 替换为:并删除#。
订单实体包含所有变量的公共getter和setter。
使用Spring数据 1.6.6
更新
似乎 JpaQueryMethod 验证器 assertParameterNamesInAnnotatedQuery 甚至不检查SpEL表单中包含的参数
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Using named parameters for method public abstract test.test.test.test.Order test.test.test.test.OrderRepository.nullSafeUpdate(test.test.test.test.Order) but parameter 'another' not found in annotated query 'UPDATE Order o SET o.serial = COALESCE(?#{#another.serial}, o.serial), o.owner = COALESCE(?#{#another.owner}, o.owner)'!