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

JPQL positional parameters are not supported

Description

Positional parameters in JPQL queries are not supported.

E.g.

1 2 3 4 5 6 public List findWithName(String name) { return em.createQuery( “SELECT c FROM Customer c WHERE c.name LIKE ?1”) .setParameter(1, name) .getResultList(); }

will return an empty list, but

1 2 3 4 5 6 public List findWithName(String name) { return em.createQuery( “SELECT c FROM Customer c WHERE c.name LIKE :name”) .setParameter("name", name) .getResultList(); }

will return the desired result (given some Customer objects in the DB).

A fully working example to reproduce the issue can be found in https://github.com/dadrus/jpa-unit/blob/master/integration-test/base/src/main/java/eu/drus/jpa/unit/test/AbstractInitialDataSetsTest.java (test4() method line 80). Just replace the query in line 82 one time by

1 2 final TypedQuery<Depositor> query = manager.createQuery("SELECT d FROM Depositor d WHERE d.surname=?1", Depositor.class); query.setParameter(1, "Doe");

and one time by

1 2 final TypedQuery<Depositor> query = manager.createQuery("SELECT d FROM Depositor d WHERE d.surname=:surname", Depositor.class); query.setParameter("surname", "Doe");

and run the tests to see the effects.

With Hibernate OGM and MongoDB it can be run using https://github.com/dadrus/jpa-unit/blob/master/integration-test/jpa-mongodb-hibernate-ogm-test/src/test/java/eu/drus/jpa/unit/test/InitialDataSetsTest.java.

If you run the same tests but for a RDBMS (e.g. from https://github.com/dadrus/jpa-unit/blob/master/integration-test/jpa2.1-hibernate-test/src/test/java/eu/drus/jpa/unit/test/InitialDataSetsTest.java) everything is fine, both cases work as expected.

This limitation makes a usage of libraries like Deltaspike Data, which e.g. generate JPQL queries based on method signatures of a DAO/Repository definitions impossible without workarounds.

Environment

None

Status

Assignee

Aleksandr Mylnikov

Reporter

Dimitrij Drus

Labels

None

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

5.1.0.Final

Priority

Major