Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344492

Summary: EntityManager.createNamedQuery().getParameters() throws NullPointerException
Product: z_Archived Reporter: Laird Nelson <ljnelson>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: RESOLVED FIXED QA Contact:
Severity: major    
Priority: P3 CC: david.minsky, michael.f.obrien
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Proposed fix, and testcase none

Description Laird Nelson CLA 2011-05-02 13:20:47 EDT
See Summary.

Steps to reproduce (assert* methods from JUnit):

EntityManagerFactory emf = ... // get an EMF
EntityManager em = emf.createEntityManager();
assertNotNull(em);
final Query q = em.createNamedQuery("someValidNamedQueryWithoutParameters");
assertNotNull(q);
q.getParameters(); // observe NPE
Comment 1 David Minsky CLA 2011-05-12 17:17:41 EDT
Created attachment 195551 [details]
Proposed fix, and testcase

Moved existing HashMap creation to be initial statement within control statement for lazy initialization.
Comment 2 David Minsky CLA 2011-05-13 12:52:48 EDT
Update to EJBQueryImpl getInternalParameters()

- Move instantiation of 'parameters' HashMap to initial statement in lazy initialization control structure to prevent a NullPointerException occurring in the situation where a query has zero parameters.

- Test emptyParametersForNonParameterizedNamedQueryTest added to JUnitJPQLParameterTestSuite

Reviewed: Andrei Ilitchev

Testing: Core LRG  JPA LRG

Checked into trunk (2.3) at r9377
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:15:17 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:30:21 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink