Hi, Tom/Michael,
Here is the fix for glassfish issue 273 and 214.
https://glassfish.dev.java.net/issues/show_bug.cgi?id=273
and
https://glassfish.dev.java.net/issues/show_bug.cgi?id=214
Please review the change. The change is in EJBQueryImpl.java to handle validation check correctly for position query such as:
1. String ejbql = "SELECT i FROM Item i WHERE i.name = ?1 AND i.itemId = ?3);
Query query = em.createQuery(ejbql);
query.setParameter(1, "Jie Leng");
query.setParameter(2, "");
query.setParameter(3, new Integer(1));
It should throw:
[java] Exception in thread "main"
java.lang.IllegalArgumentException: You have attempted to set a parameter at position 2 which does not exist in this query string SELECT i FROM Item i WHERE i.name = ?1 AND i.itemId = ?3.
2. String ejbql = "SELECT i FROM Item i WHERE i.name = ?1 AND i.itemId = ?3);
Query query = em.createQuery(ejbql);
query.setParameter(1, "Jie Leng");
query.setParameter(3, new Integer(1));
This query should be processed successfully even though ?2 is missing.
Thanks.
Jielin