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

Stephane Gallès (JIRA) noreply at atlassian.com
Wed Mar 9 08:13:08 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=40155#action_40155 ] 

Stephane Gallès commented on HHH-3494:
--------------------------------------

I've experienced the exact same problem with Hibernate 3.3.1.GA (and oracle 10/11). I had to replace a getSingleResult by a getResultList for a request "select from Foo ..." where Foo is an abstract @MappedSuperclass with three implementations with tree tables (and, hence, there are at least three SQL requests generated).

AFAICT It looks like a regression as the exact same code used to work with Hibernate 3.2.3

For me, the issue was triggered by a migration JBOSS 4.2 -> JBOSS 5.1 (ie : Hibernate 3.2.3 -> Hibernate 3.3.1)

> 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
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> 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