Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1048709 - NPE while query.list on a Native SQL, using cache
NPE while query.list on a Native SQL, using cache
Status: CLOSED CURRENTRELEASE
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate (Show other bugs)
6.1.1
All All
high Severity high
: DR2
: EAP 6.3.0
Assigned To: Brett Meyer
Zbyněk Roubalík
Russell Dickenson
:
: 1087627 (view as bug list)
Depends On:
Blocks: 1063408 1085976 1087625
  Show dependency treegraph
 
Reported: 2014-01-06 03:14 EST by Ravi Bhardwaj
Modified: 2016-07-13 18:47 EDT (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
In previous versions of JBoss EAP 6, the use of scalars within a Query, when using the Hibernate query cache, was causing users to encounter a NullPointerException. An example of a query that would produce the exception is: ---- query.addScalar("emp_first_name"); ---- The problem was caused by code that attempted to automatically identify the Hibernate Type needed to handle the scalar (StringType, for example). In this release the code has been modified to correctly identify the handler needed. For releases prior to 6.3.0, explicitly defining the type within the query scalar will avoid the NPE: ---- query.addScalar("emp_first_name", new StringType()); ----
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-06-28 11:37:33 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Ravi Bhardwaj 2014-01-06 03:14:04 EST
NPE while running the following cached NamedNativeQuery with an scalar result:

{code}
@NamedNativeQuery(name = Member.COUNT_MEMBER_QUERY, query = "SELECT COUNT(*) AS mCount from MemberHibernate4Demo", cacheable = true, readOnly = true, resultSetMapping = "Member.countQuery.Mapping")
@SqlResultSetMapping(name = "Member.countQuery.Mapping", columns =
{ @ColumnResult(name = "mCount") })
{code}

He get the following NullPointerException:
{code}
11:16:59,929 INFO  [org.jboss.as.quickstart.hibernate4.controller.MemberController] (http-/127.0.0.1:8080-1) namedQuery = SQLQueryImpl(SELECT COUNT(*) AS mCount from MemberHibernate4Demo)
11:16:59,939 INFO  [stdout] (http-/127.0.0.1:8080-1) Hibernate: SELECT COUNT(*) AS mCount from MemberHibernate4Demo
11:16:59,949 SEVERE [org.jboss.as.quickstart.hibernate4.controller.MemberController] (http-/127.0.0.1:8080-1) FIXME: Error while executing namedQuery! : java.lang.NullPointerException
	at org.hibernate.cache.internal.StandardQueryCache.put(StandardQueryCache.java:111) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
	at org.hibernate.loader.Loader.putResultInQueryCache(Loader.java:2482) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
	at org.hibernate.loader.Loader.listUsingQueryCache(Loader.java:2363) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
	at org.hibernate.loader.Loader.list(Loader.java:2324) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
	at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:338) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
	at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1827) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
	at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:231) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
	at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:157) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
	at org.hibernate.internal.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:905) [hibernate-core-4.2.0.SP1-redhat-1.jar:4.2.0.SP1-redhat-1]
	at org.jboss.as.quickstart.hibernate4.controller.MemberController.executeQuerySingleResult(MemberController.java:91) [classes:]
{code}

The issue does not occur if we disable the caching. Same as [1]

[1] https://hibernate.atlassian.net/browse/HHH-3051
Comment 1 Brett Meyer 2014-01-06 14:14:22 EST
Corrected upstream.  On hold for EAP 6.3.0 component upgrade
Comment 2 Kabir Khan 2014-04-04 11:28:22 EDT
Fixed by upgrade -> ON_QA
Comment 3 Jan Martiska 2014-04-16 08:42:53 EDT
Verified in EAP 6.3.0.ER1, hibernate 4.2.11.Final-redhat-1
Comment 4 Scott Mumford 2014-04-27 20:53:16 EDT
Brett, can you please supply a draft release note that adheres to the preformatted points in the Doc Text field above?

I'm having trouble understanding the issue and its fix for the EAP 6.3.0 release notes document.
Comment 5 Scott Mumford 2014-04-27 20:56:47 EDT
I can't seem to get my changes to the Doc Text field to stick after a save of this ticket so I'm posting them here.

The elements required for an adequate release note are:
Cause:

Consequence:

Fix:

Result:
Comment 6 Brett Meyer 2014-04-28 14:59:37 EDT
Done!
Comment 7 Scott Mumford 2014-04-28 20:06:58 EDT
Thanks Brett. That's exactly what I needed.

Reformatted the doc text and marked for inclusion in the 6.3.0 release notes documentation.
Comment 8 Martin Simka 2014-05-12 10:42:11 EDT
*** Bug 1087627 has been marked as a duplicate of this bug. ***
Comment 9 sgilda 2014-05-12 15:38:11 EDT
Changed <programlisting> tags in Doc Text to ticks (`) to fix Bug 1096865

Note You need to log in before you can comment on or make changes to this bug.