]
Strong Liu resolved HHH-1563.
-----------------------------
Resolution: Duplicate
Assignee: Strong Liu
duplicated by HHH-1423
ParameterParser - if query contains the string "call" can
cause Exception caused by check in ParameterParser.parse method
-------------------------------------------------------------------------------------------------------------------------
Key: HHH-1563
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1563
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.1.2
Environment: Java(TM) 2 Runtime Environment, Standard Edition (build
1.4.2_11-b06)
Hibernate 3.1.2 (01.27.2006)
PostgreSQL 7.4.9
Reporter: Chris Murphy
Assignee: Strong Liu
I created a query involving an object named "Call" (table call) which uncovered
a potential bug in the ParameterParser. The ParameterParser.parse(String sqlString,
Recognizer recognizer) method's first line does this check:
boolean hasMainOutputParameter = sqlString.indexOf( "call" ) > 0 &&
sqlString.indexOf( "?" ) <
sqlString.indexOf( "call" ) &&
sqlString.indexOf( "=" ) <
sqlString.indexOf( "call" );
I haven't had a chance to dig deeper so I don't know what this is used for
internally, but when I run this query:
select count(distinct s.id)) from Subscription s where s.account.bill.id = ? and s.calls
is empty
This sets "hasMainOutputParameter" to true and causes the following Exception:
org.hibernate.HibernateException: ordinal parameter mismatch
messages: [Ljava.lang.String;@6b9dfe
throwableCount: 1
throwables: [Ljava.lang.Throwable;@151a160
org.hibernate.engine.query.HQLQueryPlan.buildParameterMetadata(HQLQueryPlan.java:225)
org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:95)
org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
If I reverse the where clause of the query like so:
select count(distinct s.id)) from Subscription s where s.calls is empty and
s.account.bill.id = ?
..the check returns false as it should and the query succeeds.
I'm in a rush right now, but I'll try and dig deeper and provide a test case
and/or patch when I have a little more time.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: