JPA Query with InExpression and Collection_valued_input_parameter Complains About Bad Syntax

Description

JPA 2.0 spec final chapter 4.6.9 In Expressions

In the spec there are 3 alternatives allowed for the query argument. For the 3rd alternative there are no parenthesis allowed.

Hibernate seems to expect these illegal parenthesis.

The error occurs within a named query in an entity class.

Environment

None

Activity

Show:
Steve Ebersole
November 8, 2012, 6:59 PM

Well as I asked on the other issue, please attach a test case that reproduces this. The tests I wrote show this working perfectly fine. Even in the case of double parameter lists.

Ka Wu
March 19, 2014, 3:19 AM

Sorry for being kind of offline so long. I think the difference is that I was using lists of entities for the IN parameters :companies and :docTypes. IIRC only primitive types are allowed - at least by the JPA? Since I'm not 100% sure, can anybody confirm this? (Note I duplicated this comment onto HHH-7407, too.)

Chris
July 16, 2014, 3:04 AM

I'm experiencing this issue in Hibernate 4.2.1 Final

In out case we've got a IN placeholder as the last part of a sub query.

Something like:

SELECT column_one, (select count from XYZ where column IN arameterList) FROM ABC

The code in org.hibernate.internal.util.StringHelper.replace(String, String, String, String, boolean, boolean) on line 168 checks to see if the placeholder has both an opening backet in front of AND a closing backet after. If both of these criteria are not satisfied no backets are inserted.

A similar check to this is done in org.hibernate.internal.AbstractQueryImpl.expandParameterList(String, String, TypedValue, Map) on line 790

Hibernate doesn't realise the closing bracket after the placeholder belongs to the sub query.

Gail Badner
July 16, 2014, 7:12 AM

Chris, can you check to see if this is still a problem in 4.3? If so, please open a new Jira issue.
Thanks,
Gail

Connor Barry
November 24, 2015, 2:54 AM

I just encountered this error using Hibernate 4.3.10.Final - after adding parens around the ":myVar" the error went away. I also tried adding a space between :myVar and the close paren but no difference.

Fixed

Assignee

Gail Badner

Reporter

Guido Müller

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Blocker
Configure