【问题标题】:No data type for node: org.hibernate.hql.internal.ast.tree.MethodNode节点没有数据类型:org.hibernate.hql.internal.ast.tree.MethodNode
【发布时间】: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


【解决方案1】:

使用 coalesce 而不是 nvl ...这是 jpql 等价物

【讨论】:

    【解决方案2】:

    与 sql 查询的列不同,您需要为 HQL 引用类变量。

    参考已经回答的问题。

    No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode HQL

    【讨论】:

      猜你喜欢
      • 2021-09-23
      • 1970-01-01
      • 1970-01-01
      • 2014-12-15
      • 2016-09-19
      • 1970-01-01
      • 2016-08-11
      • 1970-01-01
      相关资源
      最近更新 更多