| Summary: | Parameter.getPosition() throws null instead of the actual position | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Stephen DiMilla <stephen.dimilla> | ||||
| Component: | Eclipselink | Assignee: | 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: |
|
||||||
Updating target milestone. Created attachment 226533 [details]
proposed fix
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 The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
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"); Set<Parameter<?>> sParameters = query.getParameters(); for (Parameter p : sParameters) { System.out.println("parameter name = " + p.getName()); System.out.println("parameter position = " + p.getPosition()); System.out.println("pParameter type =" + p.getParameterType()); if (query.isBound(p)) { System.out.println("isBound believes there is a value bound to the parameter:" + p); } else { System.out.println("query isBound = " + query.isBound(p)); } Integer pos = p.getPosition(); if (pos != null) { if (pos == 1 || pos == 2) { String sActual = p.getName(); if (sActual != null) { System.out.println("getName() - Expected: null, actual:" + sActual); } try { String sExpected = "java.lang.String"; sActual = p.getParameterType().getName(); if (!sActual.equals(sExpected)) { System.out.println("getParameterType().getName() - Expected: " + sExpected + ", actual:" + sActual); } } catch (IllegalStateException ise) { System.out.println("warning: getParameterType().getName() threw IllegalStateException, this is not considered a failure"); } } else { System.out.println("getPosition() returned an invalid position:" + pos); } } else { System.out.println("getPosition() returned null"); } --------------- Output: parameter name = 1 parameter position = null Parameter type =class java.lang.String query isBound = false getPosition() returned null --------------- Output: Reproducible: Always