【发布时间】:2018-07-20 00:33:21
【问题描述】:
我有一个带有此查询的 SpringBoot 应用程序
@Transactional
@Modifying
@Query("update HotelDailyPrice cdp set cdp.price = (select nvl (avg (cp.price),0) "
+ "from HotelPrice cp where cp.hotel = ?1 and cp.updateDate > ?2), cdp.day = ?3 where cdp.hotel = ?1 ")
void updateDailyAveragePrice (Hotel Hotel, Date dayDate, String dayDateString);
但是我收到了这个错误:
Caused by: java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode
\-[METHOD_CALL] MethodNode: '('
+-[METHOD_NAME] IdentNode: 'nvl' {originalText=nvl}
\-[EXPR_LIST] SqlNode: 'exprList'
+-[AGGREGATE] AggregateNode: 'avg'
| \-[DOT] DotNode: 'hotel1_.price' {propertyName=price,dereferenceType=PRIMITIVE,getPropertyPath=price,path=cp.price,tableAlias=hotel1_,className=com.hotels
.backend.persistence.domain.backend.HotelPrice,classAlias=cp}
| +-[ALIAS_REF] IdentNode: 'hotel1_.id' {alias=cp, className=com.hotels.backend.persistence.domain.backend.HotelPrice, tableAlias=hotel1_}
| \-[IDENT] IdentNode: 'price' {originalText=price}
\-[NUM_INT] LiteralNode: '0'
在查询中添加nvl后出现此问题
【问题讨论】:
-
您的意思是因为“NVL”在 JPQL 中不是有效函数?正如 JPA 规范所说
标签: java hibernate jpa spring-data spring-data-jpa