HQLQueryPlan gives back zero result for "getSingleResult()" although one result
is available
--------------------------------------------------------------------------------------------
Key: HHH-3494
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3494
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.1
Environment: 3.3.1.GA, hsqldb 1.8.0.7
Reporter: Christian Hofschroer
Attachments: patch.txt
I have run the following code snippets both and only the second one works, because there
is a bug in HQLQueryPlan.
// This does not work correctly (query is javax.persistence.Query)
ExampleObject e = (ExampleObject) query.getSingleResult();
// Replacement with this code works
List l=query.getResultList() ;
assertEquals(1,l.size()) ;
ExampleObject e=(ExampleObject)l.get(0) ;
This problem occurs only in seldom cases when
1. Hibernate executes several sql queries and merges the result
and
2. There is a limit of results (the limit is "2" in version 3.3.1.GA, because
only one result is expected anyway)
Attached is a patch for the class HQLQueryPlan. The line
if ( distinction.add( result ) ) {
has to be replaced with
if ( ! distinction.add( result ) ) {
In case the object was found it returns "true". With the current implementation
the object is not added to "combinedResults" although it should be added.
It was not possible to reproduce the problem with the setup from "testsuite". If
necessary I can provide a JUnit testcase.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira