Community
Participate
Working Groups
Build Identifier: Eclipselink-2.3 A NullPointerException when trying to execute a ReadAllQuery with scrollable cursor enabled. It seems that the exception happens when it tries to access the many side of the mapping. I am using Eclipselink-2.3. Here is the stack trace: Exception in thread "main" java.lang.NullPointerException at org.eclipse.persistence.internal.queries.JoinedAttributeManager.processDataResults(JoinedAttributeManager.java:1074) at org.eclipse.persistence.queries.ScrollableCursor.retrieveNextObject(ScrollableCursor.java:557) at org.eclipse.persistence.queries.ScrollableCursor.loadNext(ScrollableCursor.java:397) at org.eclipse.persistence.queries.ScrollableCursor.hasNext(ScrollableCursor.java:263) at ScrollableCursorTest.main(ScrollableCursorTest.java:80) Link to the discussion on the list: http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg06356.html Reproducible: Always Steps to Reproduce: 1. Try accessing the many side of the relationship for an entity returned by a scrollable cursor. 2. Uploaded Sample code to reproduce the issue. Testing with a simple Employee,Phone example. 3.
Created attachment 199306 [details] Sample Code to reproduce the issue Please run the code on a database containing the following two tables: 1. empinfo4 id - string name - string 2. phone4 phone - int empid - string (foreign key)
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.
Reproduced issue with a testcase based on our Employee demo: ReadAllQuery query = new ReadAllQuery(Employee.class); ExpressionBuilder builder = query.getExpressionBuilder(); query.addJoinedAttribute(builder.anyOfAllowingNone("phoneNumbers")); query.useScrollableCursor(5); ScrollableCursor cursor = (ScrollableCursor) getSession().executeQuery(query); while (cursor.hasNext()) { System.out.println(cursor.next()); } This produces: [EL Info]: ServerSession(13884241)--ThreeTierEmployee login successful [EL Fine]: ServerSession(13884241)--Connection(23664622)--SELECT DISTINCT t1.EMP_ID, t2.EMP_ID, t1.F_NAME, t1.GENDER, t1.L_NAME, t2.SALARY, t1.END_TIME, t1.START_TIME, t1.END_DATE, t1.START_DATE, t1.ADDR_ID, t1.MANAGER_ID, t1.VERSION, t0.TYPE, t0.AREA_CODE, t0.P_NUMBER, t0.EMP_ID FROM EMPLOYEE t1 LEFT OUTER JOIN PHONE t0 ON (t0.EMP_ID = t1.EMP_ID), SALARY t2 WHERE (t2.EMP_ID = t1.EMP_ID) Employee: Betty Jones Employee: John Way Employee: Sarah-Lou Smitty Employee: Fred Jones Employee: Jill May Employee: Charles Chanley Employee: Sarah-Lou Smitty Employee: Sarah Way Employee: Emanual Smith Employee: Marcus Saunders Employee: Bob Smith Employee: Jim-Bob Jefferson Employee: Charles Chanley java.lang.NullPointerException [EL Config]: ServerSession(13884241)--Connection(23664622)--disconnect at org.eclipse.persistence.internal.queries.JoinedAttributeManager.processDataResults(JoinedAttributeManager.java:1074) at org.eclipse.persistence.queries.ScrollableCursor.retrieveNextObject(ScrollableCursor.java:557) at org.eclipse.persistence.queries.ScrollableCursor.loadNext(ScrollableCursor.java:397) at org.eclipse.persistence.queries.ScrollableCursor.hasNext(ScrollableCursor.java:263) at examples.sessions.threetier.examples.ScrollableCursorTest.run(ScrollableCursorTest.java:25) at examples.sessions.threetier.Example.runExample(Example.java:57) at examples.sessions.threetier.examples.ScrollableCursorTest.main(ScrollableCursorTest.java:31)
Potentially related to: Bug 309142 - ScrollableCursor hasNext() throws DB exception instead of returning false at end of iteration
Created attachment 200400 [details] Proposed patch and testcase
Created attachment 205852 [details] Patch and testcase Patch fixes ScrollableCursor retrieveNextObject(), and moves positioning code block before the joining check to fix the occurrence of a NPE.
Created attachment 205859 [details] Patch and testcase Minor modification to testing
Created attachment 205864 [details] Patch and testcase Adjusted copyright header on test, and removed unused import
Checked into trunk (2.4) at revision: 10266
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink