[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3494) HQLQueryPlan gives back zero result for "getSingleResult()" although one result is available

Christian Hofschroer (JIRA) noreply at atlassian.com
Thu Sep 25 09:39:04 EDT 2008


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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list