| This bug is the same as HH-10885, except for {{NamedQuery}}s and {{NamedNativeQuery}}s instead of {{NativeQuery}}s The problem is that the position (ordinal paramer) in Query.setParameter(int, Object) is zero based. JPA 2.1 spec states that the ordinal parameters should be 1-based. This works (but shouldn't)
Query query = entityManager.createNamedQuery("MyQuery");
query.setParameter(0, "MyParameter");
List list = query.getResultList();
This causes {{IllegalArgumentException}}s, but should work
Query query = entityManager.createNamedQuery("MyQuery");
query.setParameter(1, "MyParameter");
List list = query.getResultList();
A workaround is to use specific positions in the statement (e.g. ... where id = ?1 instead of ... where id = ? ) Arquillian test case is attached (can be run with mvn verify ) I believe this affects all Hibernate 5 versions (tested with 5.1.0.Final, 5.2.0.Final and 5.2.2.Final) |