Bug 1048709 - NPE while query.list on a Native SQL, using cache
Summary: NPE while query.list on a Native SQL, using cache
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate
Version: 6.1.1
Hardware: All
OS: All
Target Milestone: DR2
: EAP 6.3.0
Assignee: Brett Meyer
QA Contact: Zbyněk Roubalík
Russell Dickenson
: 1087627 (view as bug list)
Depends On:
Blocks: 1063408 1085976 1087625
TreeView+ depends on / blocked
Reported: 2014-01-06 08:14 UTC by Ravi Bhardwaj
Modified: 2018-12-05 16:51 UTC (History)
9 users (show)

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()); ----
Clone Of:
Last Closed: 2014-06-28 15:37:33 UTC
Type: Bug

Attachments (Terms of Use)

Description Ravi Bhardwaj 2014-01-06 08:14:04 UTC
NPE while running the following cached NamedNativeQuery with an scalar result:

@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") })

He get the following NullPointerException:
11:16:59,929 INFO  [org.jboss.as.quickstart.hibernate4.controller.MemberController] (http-/ namedQuery = SQLQueryImpl(SELECT COUNT(*) AS mCount from MemberHibernate4Demo)
11:16:59,939 INFO  [stdout] (http-/ Hibernate: SELECT COUNT(*) AS mCount from MemberHibernate4Demo
11:16:59,949 SEVERE [org.jboss.as.quickstart.hibernate4.controller.MemberController] (http-/ 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:]

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 19:14:22 UTC
Corrected upstream.  On hold for EAP 6.3.0 component upgrade

Comment 2 Kabir Khan 2014-04-04 15:28:22 UTC
Fixed by upgrade -> ON_QA

Comment 3 Jan Martiska 2014-04-16 12:42:53 UTC
Verified in EAP 6.3.0.ER1, hibernate 4.2.11.Final-redhat-1

Comment 4 Scott Mumford 2014-04-28 00:53:16 UTC
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-28 00:56:47 UTC
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:




Comment 6 Brett Meyer 2014-04-28 18:59:37 UTC

Comment 7 Scott Mumford 2014-04-29 00:06:58 UTC
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 14:42:11 UTC
*** Bug 1087627 has been marked as a duplicate of this bug. ***

Comment 9 sgilda 2014-05-12 19:38:11 UTC
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.