【发布时间】:2020-09-22 16:59:35
【问题描述】:
我正在从 Hibernate 4 升级到 Hibernate 5。应用程序启动时出现以下错误。
org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:第 1 行附近的 FETCH
命名查询具有“仅获取第一个?仅行”,这在 hibernate 4 中运行良好。不知道如何解决这个问题。我正在使用 DB2 方言。我也使用过jpa 2.2。 我在下面的文章中找到了它,但它是针对 Oracle 的。 Hibernate 5 change not to use fetch first rows only
谢谢,
【问题讨论】:
-
我注意到在 org.hibernate.hql.internal.antlr.HqlBaseParser 中 orderElement() 方法的实现在 Hibernate 5 中已经改变了。所以没有办法添加 "fetch first ? rows仅”在命名查询中前进。只是更改方言或添加 Spring Boot 配置无法解决此问题。
标签: spring-boot hibernate jpa orm hibernate-5.x