Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 364442 - NPE caused by concurrent usage of Query.setHint on named query with join-fetch/batch
Summary: NPE caused by concurrent usage of Query.setHint on named query with join-fetc...
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: Other other
: P2 critical (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-22 02:44 EST by Sven Hoffmann CLA
Modified: 2022-06-09 10:29 EDT (History)
2 users (show)

See Also:


Attachments
Stacktrace of NullPointerException (1.09 KB, text/plain)
2011-11-22 02:45 EST, Sven Hoffmann CLA
no flags Details
Suggested patch (for trunk) (9.76 KB, patch)
2012-03-06 17:23 EST, Andrei Ilitchev CLA
no flags Details | Diff
Test fix - the test should not run on app. server (746 bytes, patch)
2012-03-08 10:46 EST, Andrei Ilitchev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Hoffmann CLA 2011-11-22 02:44:03 EST
Build Identifier: 2.3.1.v20111014-r10236

As described in "NullPointerException in Query.setHint with join-fetch/batch" (http://www.eclipse.org/forums/index.php/t/262488) a NullPointerException occurs while using Query.setHint on a named query with join-fetch/batch.

The code performing the query looks like:
Query query = em.createNamedQuery(Container.LOAD_BY_ORDER);
query.setParameter("orderId", id);
query.setHint(QueryHints.FETCH, "c.attribute1");
query.setHint(QueryHints.BATCH, "c.attribute3");
List result = query.getResultList();

The application uses EclipseLink 3.2.1 M8 and is hosted on WebSphere Application Server 7.0 FP17 on an AIX system. The query is concurrently performed by message driven beans.
After one failure all subsequent calls fail with the same exception until the server is restarted.

It should be possible to execute the code above concurrently without getting a NullPointerException.



Reproducible: Sometimes

Steps to Reproduce:
Concurrent calls of Query.setHint on named query with join-fetch/batch.
Comment 1 Sven Hoffmann CLA 2011-11-22 02:45:11 EST
Created attachment 207346 [details]
Stacktrace of NullPointerException
Comment 2 Tom Ware CLA 2011-11-22 07:44:41 EST
Please describe the level of concurrency (i.e. what is shared between threads?)

Is it the EntityManager?  The EntityManagerFactory?  The query?
Comment 3 Sven Hoffmann CLA 2011-11-22 07:52:13 EST
(In reply to comment #2)
> Please describe the level of concurrency (i.e. what is shared between threads?)
> 
> Is it the EntityManager?  The EntityManagerFactory?  The query?
The application (stateful session bean) shares none of these.

James in http://www.eclipse.org/forums/index.php/mv/msg/262488/758040/#msg_758040
> The issue is although the hint causes different queries to be used, the same expression is still used, causing the concurrency issue.
As far as I understood James in the related post the expression of the named query is internally shared between threads.
Comment 4 Tom Ware CLA 2011-12-02 10:25:39 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 5 Andrei Ilitchev CLA 2012-03-06 17:23:35 EST
Created attachment 212173 [details]
Suggested patch (for trunk)
Comment 6 Andrei Ilitchev CLA 2012-03-07 10:45:41 EST
The patched checked into both trunk and 2.3.3.
Comment 7 Andrei Ilitchev CLA 2012-03-08 10:46:47 EST
Created attachment 212300 [details]
Test fix - the test should not run on app. server
Comment 8 Andrei Ilitchev CLA 2012-03-08 10:54:32 EST
The patched checked into both trunk and 2.3.3.
Comment 9 Eclipse Webmaster CLA 2022-06-09 10:29:27 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink