Message:
A new issue has been created in JIRA.
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-297
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-297
Summary: Named Parameters not recognized in 'order by' section of Query
Type: Bug
Status: Unassigned
Priority: Major
Project: Hibernate2
Components:
core
Versions:
2.0.1
2.0.2
2.1 beta 1
2.1 beta 2
Assignee:
Reporter: Roberto S. Tyley
Created: Thu, 28 Aug 2003 8:39 AM
Updated: Thu, 28 Aug 2003 8:39 AM
Environment: java.version=1.4.2
os.name=Windows 2000
Mckoi DB 1.0.2
Description:
The following query using named parameters fails:
Query q=session.createQuery("from Location loc where (loc.lonLat.UnitX between :minX and :maxX) order by ABS( loc.lonLat.UnitX - :centX )");
q.setDouble("minX", x - r);
q.setDouble("maxX", x + r);
q.setDouble("centX", x);
Iterator locs = q.iterate(); // Fails with QueryException
The final bit with 'centX' causes the problem, as the following query, with the 'centX' removed, succeeds:
Query q=session.createQuery("from Location loc where (loc.lonLat.UnitX between :minX and :maxX) order by ABS( loc.lonLat.UnitX )");
q.setDouble("minX", x - r);
q.setDouble("maxX", x + r);
Iterator locs = q.iterate(); // Succeeds
Also, using JDBC-style un-named parameters works:
Query q=session.createQuery("from Location loc where (loc.lonLat.UnitX between ? and ?) order by ABS( loc.lonLat.UnitX - ? )");
q.setDouble(0, x - r);
q.setDouble(1, x + r);
q.setDouble(2, x);
Iterator locs = q.iterate(); // Succeeds
Both of these two succeeding queries bring back all the results I would expect, with the correct ordering - so none of the function-calls or presence of a parameter in the order-by clause should be illegal.
The full stack trace is:
net.sf.hibernate.QueryException: Named parameter does not appear in Query: centX [from com.thisbedisonfire.madgag.persistence.Location loc where (loc.lonLat.UnitX between :minX and :maxX) order by ABS( loc.lonLat.UnitX - :centX )]
at net.sf.hibernate.hql.QueryTranslator.getNamedParameterLocs(QueryTranslator.java:437)
at net.sf.hibernate.hql.QueryTranslator.bindNamedParameters(QueryTranslator.java:817)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:575)
at net.sf.hibernate.hql.QueryTranslator.iterate(QueryTranslator.java:832)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1436)
at net.sf.hibernate.impl.QueryImpl.iterate(QueryImpl.java:29)
at com.thisbedisonfire.madgag.Main.main(Main.java:105)
So, something's going wrong with binding of named parameters...
Hope you can help!
Roberto S. Tyley
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|