The JPA spec doesn't state that JPQL positional parameters must be a sequence.
Hibernate in case when they are not, e.g.
SELECT foo FROM Foo foo WHERE foo IN (?1, ?3)
throws
java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: Position beyond number of declared ordinal parameters. Remember that ordinal parameters are 1-based! Position: 4
This is user-unfriendly when the JPQL is constructed with conditions and loops. I think that it's rational to expect the following to work.
returnthis.em.createQuery("SELECT ma FROM MavenArtifact ma "
+ " WHERE ma.groupId = ?1"
+ " AND ma.artifactId = ?2"
+ " AND ma.version = ?3"
+ " AND (" + packCond + ") "
+ " AND ma.classifier = ?5"
, MavenArtifact.class)
.setParameter(1, groupId)
.setParameter(2, artifactId)
.setParameter(3, version)
.setParameter(4, packaging)
.setParameter(5, classifier)
.getSingleResult();
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira