View | Details | Raw Unified | Return to bug 351509 | Differences between
and this patch

Collapse All | Expand All

(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/queries/QueryFrameworkTestSuite.java (+1 lines)
Lines 63-68 Link Here
63
        addTest(buildArgumentValuesTest());
63
        addTest(buildArgumentValuesTest());
64
        addTest(new ScrollableCursorForwardOnlyResultSetTest()); // Bug 309142
64
        addTest(new ScrollableCursorForwardOnlyResultSetTest()); // Bug 309142
65
        addTest(new ConformResultsSubclassesTest()); // Bug 327900
65
        addTest(new ConformResultsSubclassesTest()); // Bug 327900
66
        addTest(new ScrollableCursorJoinedAttributeTest()); // Bug 351509
66
    }
67
    }
67
68
68
    //SRG test set is maintained by QA only, do NOT add any new test cases into it.
69
    //SRG test set is maintained by QA only, do NOT add any new test cases into it.
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/queries/ScrollableCursorJoinedAttributeTest.java (+70 lines)
Line 0 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 1998, 2011 Oracle. All rights reserved.
3
 * This program and the accompanying materials are made available under the 
4
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 
5
 * which accompanies this distribution. 
6
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7
 * and the Eclipse Distribution License is available at 
8
 * http://www.eclipse.org/org/documents/edl-v10.php.
9
 *
10
 * Contributors:
11
 *     dminsky - initial API and implementation
12
 ******************************************************************************/  
13
package org.eclipse.persistence.testing.tests.queries;
14
15
import java.util.List;
16
import java.util.Vector;
17
18
import org.eclipse.persistence.queries.ReadAllQuery;
19
import org.eclipse.persistence.queries.ScrollableCursor;
20
21
import org.eclipse.persistence.testing.framework.TestCase;
22
import org.eclipse.persistence.testing.models.employee.domain.Employee;
23
24
/**
25
 * Test using a ScrollableCursor with a simple joined attribute.
26
 * Bug 351509 - Null Pointer Exception when using ScrollableCursor on a OneToMany Mapping 
27
 */
28
public class ScrollableCursorJoinedAttributeTest extends TestCase {
29
    
30
    protected List cursoredResults;
31
    protected Exception caughtException;
32
    
33
    public ScrollableCursorJoinedAttributeTest() {
34
        super();
35
        setDescription("Scrollable Cursor Test incorporating a joined attribute");
36
    }
37
    
38
    public void test() {
39
        getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
40
        
41
        cursoredResults = new Vector();
42
        ReadAllQuery cursoredQuery = new ReadAllQuery(Employee.class);
43
        cursoredQuery.useScrollableCursor();
44
        cursoredQuery.addJoinedAttribute(cursoredQuery.getExpressionBuilder().anyOfAllowingNone("phoneNumbers"));
45
        cursoredQuery.addOrdering(cursoredQuery.getExpressionBuilder().get("id"));
46
        
47
        try {
48
            ScrollableCursor cursor = (ScrollableCursor)getSession().executeQuery(cursoredQuery);
49
            while (cursor.hasNext()) {
50
                Object result = cursor.next();
51
                cursoredResults.add(result);
52
            }
53
            cursor.close();
54
        } catch (Exception e) {
55
            caughtException = e;
56
        }
57
    }
58
    
59
    public void verify() {
60
        if (caughtException != null) {
61
            throwError("Cursored query should not result in an exception", caughtException);
62
        }
63
        assertNotSame("Test data for cursored results should be nonzero", 0, cursoredResults.size());
64
    }
65
    
66
    public void reset() {
67
        this.cursoredResults = null;
68
    }
69
70
}
(-)foundation/org.eclipse.persistence.core/src/org/eclipse/persistence/queries/ScrollableCursor.java (-6 / +6 lines)
Lines 550-555 Link Here
550
                row = this.nextRow;
550
                row = this.nextRow;
551
                this.nextRow = null;
551
                this.nextRow = null;
552
            }
552
            }
553
            
554
            this.position = currentPosition + 1;  // bug 309142
555
            if (row == null) {
556
                return null;
557
            }
558
            
553
            // If using 1-m joining need to fetch 1-m rows as well.
559
            // If using 1-m joining need to fetch 1-m rows as well.
554
            if (this.query.isObjectLevelReadQuery() && ((ObjectLevelReadQuery)this.query).hasJoining()) {
560
            if (this.query.isObjectLevelReadQuery() && ((ObjectLevelReadQuery)this.query).hasJoining()) {
555
                JoinedAttributeManager joinManager = ((ObjectLevelReadQuery)this.query).getJoinedAttributeManager();
561
                JoinedAttributeManager joinManager = ((ObjectLevelReadQuery)this.query).getJoinedAttributeManager();
Lines 558-569 Link Here
558
                }
564
                }
559
            }
565
            }
560
            
566
            
561
            this.position = currentPosition + 1;  // bug 309142
562
            
563
            if (row == null) { 
564
                return null;
565
            }
566
567
            Object object = buildAndRegisterObject(row);
567
            Object object = buildAndRegisterObject(row);
568
            if (object == InvalidObject.instance) {
568
            if (object == InvalidObject.instance) {
569
                continue;
569
                continue;

Return to bug 351509