We're updating the issue view to help you get more done. 

JPA Native Queries with ordinal parameter are zero based

Description

According to my understanding of the [JPA 2.1 specification](http://download.oracle.com/otn-pub/jcp/persistence-2_1-fr-eval-spec/JavaPersistence.pdf) 3.10.13 Positional Parameters: ordinal parameters should be 1 based. Even for native queries.

I raised the issue at [StackOverflow ](http://stackoverflow.com/questions/37973915/hibernate-positional-parameters-zero-based)

In the code snippet below, parameter index should be 1 not 0.

1 2 3 Query query = entityManager.createNativeQuery("select * from Game g where title = ?"); query.setParameter(0, GAME_TITLES[0]); List list = query.getResultList();

With hibernate 4.2.6 this is working correctly

I added a small Arquillian test to demonstrate the problem

When using indexed ordinal parameter this works

1 2 Query query = entityManager.createNativeQuery("SELECT * FROM Game g WHERE title = ?1"); query.setParameter(1, GAME_TITLES[0]);

Environment

Java 1.8.0_74
Hibernate 5.2.0.Final
Windows 7

Status

Assignee

Andrea Boriero

Reporter

F

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

5.2.0

Priority

Major