This bug is the same as HH-10885, except for {{ NamedQuery NamedQueries }} s and {{ NamedNativeQuery NamedNativeQueries }} s instead of {{ NativeQuery NativeQueries }} 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) {code} Query query = entityManager.createNamedQuery("MyQuery"); query.setParameter(0, "MyParameter"); List list = query.getResultList(); {code}
This causes {{ IllegalArgumentException IllegalArgumentExceptions }} s , but should work {code} Query query = entityManager.createNamedQuery("MyQuery"); query.setParameter(1, "MyParameter"); List list = query.getResultList(); {code}
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) |
|