Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 344492 - EntityManager.createNamedQuery().getParameters() throws NullPointerException
Summary: EntityManager.createNamedQuery().getParameters() throws NullPointerException
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: Macintosh Mac OS X - Carbon (unsup.)
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-02 13:20 EDT by Laird Nelson CLA
Modified: 2022-06-09 10:30 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix, and testcase (2.71 KB, patch)
2011-05-12 17:17 EDT, David Minsky CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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