Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 366530

Summary: Parameter.getParameter(int, class) does not throw IllegalArgumentException when the parameter is not assignable to the type
Product: z_Archived Reporter: Stephen DiMilla <stephen.dimilla>
Component: EclipselinkAssignee: Nobody - feel free to take it <nobody>
Status: CLOSED FIXED QA Contact:
Severity: blocker    
Priority: P3 CC: lance.andersen, stephen.dimilla, tom.ware
Version: unspecified   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
proposed fix
none
additional patch none

Description Stephen DiMilla CLA 2011-12-13 08:48:23 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 query = em.createQuery(
                    "select e from Employee e where e.firstName = ?1").setParameter(1, "Tom");
            query.getParameter(1, java.util.List.class);
            System.out.println("IllegalArgumentException not thrown");
        } catch (IllegalArgumentException e) {
            System.out.println("Received expected IllegalArgumentException");
        } catch (Exception e) {
            System.out.println("Unexpected exception occurred", e);
        }

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


IllegalArgumentException not thrown


Reproducible: Always
Comment 1 Tom Ware CLA 2012-04-05 11:01:19 EDT
Updating target milestone.
Comment 2 Tom Ware CLA 2013-02-04 15:19:47 EST
Created attachment 226532 [details]
proposed fix
Comment 3 Tom Ware CLA 2013-02-04 15:35:46 EST
Fix for JPA 2.1 Query Parameter Bugs 357089, 366526, 366530, 366576 checked in together

Reviewed by Guy Pelletier

Added QueryTestSuite to JPA 2.1 testing

Tested with JPA LRG
Comment 4 Tom Ware CLA 2013-02-20 10:07:34 EST
Created attachment 227339 [details]
additional patch
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:36:05 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink