Issue Type: Bug Bug
Affects Versions: 4.2.2
Assignee: Unassigned
Components: query-sql
Created: 05/Jul/13 12:21 AM
Description:

The following queries fail in hibernate due to what seems like incorrect logic for determining whether the parameter needs to be surrounded by parentheses.

select * from (
select e.name, d.name from employee  =e
join department d on e.deptid = d.id
where d.id in :deptIds
)
with empDepts as (
select e.name, d.name from employee  =e
join department d on e.deptid = d.id
where d.id in :deptIds
) select * from empDepts

The problem seems to be that Hibernate treats the closing parenthese after :deptIds as already "enclosing" the parameterList so doesn't add parentheses, thus making the query invalid.

Workaround 1: Add dummy whitespace after the deptIds binding

select * from (
select e.name, d.name from employee  =e
join department d on e.deptid = d.id
where d.id in :deptIds
)

Workaround 2: Put the parentheses in yourself (better)

select * from (
select e.name, d.name from employee  =e
join department d on e.deptid = d.id
where d.id in (:deptIds)
)
Environment: Oracle 11.2.0.3
Java 6
Project: Hibernate ORM
Priority: Major Major
Reporter: Chad Wilson
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira