Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 366549 - Query.getParameterValue(int) does not throw IllegalStateException when the parameter has not been been bound
Summary: Query.getParameterValue(int) does not throw IllegalStateException when the pa...
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:04 EST by Stephen DiMilla CLA
Modified: 2022-06-09 10:25 EDT (History)
3 users (show)

See Also:


Attachments
proposed fix (2.21 KB, patch)
2013-02-13 13:22 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:04:50 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:

       try {
            Query query = em.createQuery("select e from Employee e where e.firstName = ?1");
            query.getParameterValue(1);
            System.out.println("IllegalStateException not thrown");
        } catch (IllegalStateException e) {
            System.out.println("Received expected IllegalStateException");
        } catch (Exception e) {
            System.out.println("Unexpected exception occurred", e);
        }

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

Unexpected exception occurred
java.lang.IllegalArgumentException: No paramter with name : fname1 was found within the query: ReadAllQuery(referenceClass=Employee sql="SELECT ID, FIRSTNAME FROM EMPLOYEE WHERE (FIRSTNAME = ?)").
[javatest.batch] 	
	at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getParameterValue(EJBQueryImpl.java:1437)

Reproducible: Always
Comment 1 Tom Ware CLA 2012-04-05 11:01:13 EDT
Updating target milestone.
Comment 2 Tom Ware CLA 2013-02-04 15:07:10 EST
IllegalArgumentException should be the expected exception according to the current version of the spec.
Comment 3 Tom Ware CLA 2013-02-13 13:22:57 EST
Created attachment 227036 [details]
proposed fix
Comment 4 Tom Ware CLA 2013-02-13 13:23:44 EST
Looks like I misread the spec.

Fix checked in - simply changes the exeption thrown

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