收到“错误”:“ <表达式>,<运算符>,GROUP,HAVING或ORDER预期为'('”

时间:2018-10-08 18:35:35

标签: java intellij-idea hql

IntelliJ IDEA Ultimate向我显示错误:

  

<expression>,<operator>, GROUP, HAVING or ORDER expected got '('

在HQL语句内的紧要关头之下,这显然不是编译或运行时的问题。

@Query("SELECT offer FROM OfferEntity offer " +
        "   JOIN offer.placeOwnership AS owner " +
        "   JOIN owner.place AS place " +
        "WHERE " +
        "   place.id = :placeId AND " +
        "   to_char(offer.dayFrom, 'yyyy-MM-dd') = :offerDate AND " +
                   ^
        <expression>,<operator>, GROUP, HAVING or ORDER expected got '('
        "   offer.repeating = false")
List<OfferEntity> getAllForDate(@Param("placeId") Long placeId, @Param("offerDate") String offerDate);

有人知道为什么会发生这种情况以及如何摆脱这种情况吗?这很烦人并且令人误解(大概是因为代码在运行)。

enter image description here

1 个答案:

答案 0 :(得分:0)

https://www.baeldung.com/spring-data-jpa-query -> 在 2.2 Native

@Query(
  value = "SELECT * FROM USERS u WHERE u.status = 1", 
  nativeQuery = true)

为我们工作。您需要添加“值=”和“, @Query 中的 nativeQuery = true”