Bug 1096267 - HHH-9154 "class" string cannot be used as parameter name in HQL anymore, causing org.hibernate.hql.internal.ast.QuerySyntaxException
Summary: HHH-9154 "class" string cannot be used as parameter name in HQL anymore, caus...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate
Version: 6.3.0
Hardware: Unspecified
OS: Unspecified
low
medium
Target Milestone: ER6
: EAP 6.3.0
Assignee: Gail Badner
QA Contact: Martin Simka
Russell Dickenson
URL:
Whiteboard:
Depends On:
Blocks: 1100862
TreeView+ depends on / blocked
 
Reported: 2014-05-09 14:25 UTC by Marek Schmidt
Modified: 2014-06-28 15:30 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-06-28 15:30:54 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Marek Schmidt 2014-05-09 14:25:58 UTC
Description of problem:

HQL such as

 Query query = entityManager.createQuery("select u from Foo u where u.travelClass = :class");
query.setParameter("class", travelClass);

was OK in EAP 6.2, but fails on EAP 6.3 since ER2

Version-Release number of selected component (if applicable):
Hibernate 4.2.12.Final-redhat-1

How reproducible:
Always

Steps to Reproduce:
1. Change the EAP "greeter" quickstart src/main/java/org/jboss/as/quickstarts/greeter/domain/ManagedBeanUserDao.java

to

Query query = entityManager.createQuery("select u from User u where u.username = :class");
query.setParameter("class", username);

3. deploy, run and enter name "jdoe"

Actual results:
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: : near line 1, column 81 [select u from org.jboss.as.quickstarts.greeter.domain.User u where u.username = :class]

Expected results:
Application should greet jdoe.

Additional info:

An example application using "class" in parameter name has been spotted in the wild:

https://github.com/spring-projects/spring-ws-samples/blob/master/airline/server/src/main/java/org/springframework/ws/samples/airline/dao/jpa/JpaFlightDao.java

Comment 1 Brett Meyer 2014-05-09 16:51:44 UTC
Changing this to low priority since it's really simple to workaround (just change the param name).  Honestly, this should probably be a WONTFIX, as "class" has always been reserved in HQL (at least I thought it was).  The fact that it "worked" up until now was probably a fluke.  HQL received several important fixes between EAP 6.2 and 6.3 that probably exposed this.

Comment 2 Brett Meyer 2014-05-09 16:55:48 UTC
We recently rejected a few others that were related:
https://hibernate.atlassian.net/browse/HHH-9154

Comment 3 Marek Schmidt 2014-05-12 10:08:18 UTC
Is there any list of all the reserved keywords that might be affected, so that they can be added to the release notes?

Comment 4 Gail Badner 2014-05-13 18:31:09 UTC
This really should be treated as a regression so I'm raising the severity back to high. I'm looking into this.

Comment 5 Gail Badner 2014-05-15 19:54:07 UTC
HHH-9154 was re-opened and fixed. The fix has been backported to 4.3 and 4.2.

Comment 6 Gail Badner 2014-05-15 21:15:23 UTC
I've asked Steve Ebersole about reserved words affected by this bug. I'll provide them when I get an answer.

Comment 7 Gail Badner 2014-05-15 21:29:11 UTC
I would not say this is a blocker. It can be deferred.

Comment 8 Marek Schmidt 2014-05-19 11:27:42 UTC
Either it is a regression, in which case it has be fixed now, therefore would be a blocker, or it is not a regression in which case it doesn't have to be fixed at all. 

Deferring it now would mean affected users would have to migrate their applications anyway for EAP 6.3 and then later allowed to migrate to their old queries back again when this is fixed, which would be silly. 

The only way this issue should not be considered a regression and therefore not a blocker, would be if the HQL indeed forbade ':keywords' as parameter names, in which case the current behavior would not be a bug, but a bug fix.

Comment 9 Martin Simka 2014-05-19 11:41:05 UTC
I agree that this is regression. It could affect existing customers' applications therefore I'm adding blocker? flag.

Comment 10 Brett Meyer 2014-05-19 14:22:49 UTC
Corrected under https://hibernate.atlassian.net/browse/HHH-9154

Comment 11 Brett Meyer 2014-05-19 16:24:25 UTC
I'm ok with fixing it in 6.3, but I'll wait to act until we get the ACKs.  I'm not sure where we're currently at in the schedule.

Comment 12 Gail Badner 2014-05-22 19:44:53 UTC
I will release hibernate-orm 4.2.13.Final with the fix by Wednesday 5/28. David Stahl will take it from there.

Comment 13 Gail Badner 2014-05-22 19:52:31 UTC
IIUC, this does not need to be in the release notes, since this was a regression that turned up in EAP 6.3 ER2, that will be fixed in 6.3.0.

Comment 14 Marek Schmidt 2014-05-23 11:00:53 UTC
Indeed.

Comment 15 Jan Martiska 2014-06-12 10:22:12 UTC
Verified in EAP 6.3.0.ER7.
There is also a new testcase for this feature: org.hibernate.test.hql.ParameterTest and it passes.


Note You need to log in before you can comment on or make changes to this bug.