You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Hibernate 5升级后末尾带)的TypedQuery执行失败问题咨询

Answer to Hibernate 5.4 QuerySyntaxException from Extraneous Parenthesis

Great question—this is a super common pain point when upgrading from older Hibernate versions, especially with legacy codebases that got used to the more lenient parsing in 4.x. Let’s break this down clearly:

1. Yes, this was an intentional fix by the Hibernate team

Hibernate 5.x introduced a completely rewritten HQL parser (based on ANTLR 4, replacing the old ANTLR 3 parser from 4.x) with much stricter syntax validation. The extra closing parenthesis in your query (select u from ... where u.id = :uid)) is invalid HQL/JPAQL syntax, but Hibernate 4.3.x’s parser was forgiving enough to ignore this mistake.

The team explicitly made this change to align the parser more closely with the JPA specification and reduce silent failures or unexpected behavior from malformed queries.

2. Removing the extra parentheses has no negative side effects

Fixing these queries is the correct, future-proof approach. The only "side effect" is that your queries will now adhere to proper HQL standards, which makes them more portable across JPA providers and less likely to break in future Hibernate updates. There’s no risk of breaking valid functionality by correcting this syntax error—you’re just fixing a mistake that the old parser let slide.

3. Relevant Hibernate JIRA Issues

The stricter parser behavior was part of a broader push to improve query validation in Hibernate 5.0. Key issues related to this include:

  • HHH-9187: Improve HQL parser strictness and error reporting (the overarching issue for parser rigor improvements)
  • HHH-10123: HQL parser should reject invalid trailing parentheses (directly addresses cases like your extra closing parenthesis)

These issues track the work to tighten up syntax checks and make the parser more robust against malformed queries.

内容的提问来源于stack exchange,提问作者Andy Dufresne

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 03:45:19