Community
Participate
Working Groups
Build Identifier: EclipseLink, version: Eclipse Persistence Services - 2.2.0.v20101209-r8662 While querying for a boolean value in one of my entities, I was consistently getting NoResultException exceptions when calling getSingleResult(). When manually running the SQL against my database I would get the result I was looking for. I then ran a native SQL query as well as the original query with FINEST logging turned on. It turns out my native SQL was creating a DataReadQuery which would return the boolean I was looking for. The CriteriaQuery would create a ReportQuery which would return no rows. Reproducible: Always Steps to Reproduce: 1. Use CriteriaBuilder to query for a single Boolean entity attribute 2. call getSingleResult()
Do you get a similar issue when running equivalent JPQL
Hi Tom, Yes, the same result. JPQL produces another ReportQuery which returns no results. Running the SQL myself that is generated, which is the same SQL the CriteriaBuilder produced, produces a single boolean value so there should be something being returned but no joy. The boolean column I am querying on is a protected member of a MappedSuperclass. Would this cause any problems that you know of? At the moment, my workaround is to count the rows returned instead of asking for the boolean value itself. That works. Thanks!
I am not aware of any issue with querying a protected member of a mapped superclass.
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
This issue is due to a fix put into TopLink Essentials (glassfish bug 295) to filter out duplicates hen Distinct is used. Unfortunately, the constant used to indicate a duplicate is ReportyQuery's static RESULT_IGNORED, which is set to Boolean.valueOf(true). This causes single Boolean values of True to be excluded from the returned results (in ReportyQuery's buildObjects method) Workaround is to return the entity and then get the boolean value from it directly.
*** Bug 348874 has been marked as a duplicate of this bug. ***
Created attachment 259759 [details] Patch for Bug 335797 - make Boolean instance unique
Bug 340089 is another duplicate of this bug. I have attached a fix with minimal side effects to this bug report, perhaps voting with joined forces brings it in:).
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink