Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366556 - Query.getFlushMode() throws NullPointerException instead of the flush mode in effect for the entity manager when a flush mode has not been set for the query object .
Summary: Query.getFlushMode() throws NullPointerException instead of the flush mode in...
Status: CLOSED 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 blocker (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-13 10:36 EST by Stephen DiMilla CLA
Modified: 2022-06-09 10:28 EDT (History)
3 users (show)

See Also:


Attachments
proposed fix (2.73 KB, patch)
2013-02-06 09:42 EST, Tom Ware CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen DiMilla CLA 2011-12-13 10:36:43 EST
Build Identifier: eclipselink-2.3.0.v20110604-r9504

Using the entity:
@Entity
@Table(name = "EMPLOYEE")
public class Employee implements java.io.Serializable, Comparable<Employee> {

    private int id;
    private String firstName;

    public Employee() {
    }

    public Employee(int id, String firstName) {
        this.id = id;
        this.firstName = firstName;
    }



    // ===========================================================
    // getters and setters for the state fields

    @Id
    @Column(name = "ID")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "FIRSTNAME")
    public String getFirstName() {
        return firstName;
    }

----------------
Client Code:

            Query q = em.createQuery("SELECT c FROM Customer c WHERE c.name = 'Michael Bouschen'");
            System.out.println("EntityManager.getFlushMode() returned:"+em.getFlushMode());
            System.out.println("Calling Query.getFlushMode()");
            FlushModeType fmt = q.getFlushMode();

---------------
Output:


EM.getFlushMode() returns:AUTO
Calling getFlushMode()
Caught unexpected exception: java.lang.NullPointerException
java.lang.NullPointerException
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getFlushMode(EJBQueryImpl.java:1324)

Reproducible: Always
Comment 1 Tom Ware CLA 2012-04-05 11:01:16 EDT
Updating target milestone.
Comment 2 Tom Ware CLA 2013-02-06 09:42:17 EST
Created attachment 226631 [details]
proposed fix
Comment 3 Tom Ware CLA 2013-02-06 09:44:45 EST
Fix checked in... adds a null check.

Reviewed by Guy Pelletier

Added test to JPA 2.1 Query Test Suite

Tested with JPA LRG
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:28:09 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink