-->

vendredi 5 décembre 2014

JPA-style positional param was not an integral ordinal

Introduction :

"JPA-style positional param was not an integral ordinal"

One problem that requires a bit of thought to solve this error or exception thrown when developping an application using JPA and Hibernate like a reference implementation.

To solve this problem, we must see the origin of this error, it is a poorly written application that can not interpreted by the Hibernate ORM.

Take an example of a native SQL query to understand who the resolve this problem : 

query = "SELECT u from User u"
      + "INNER JOIN ON g.grp_id Group g = u.grp_id"
      + "and grp.grp_name = ?1";

At the first sight, there is no space at the end od the second line of the concatenated String and Hibernate can not interpret this query. 

To solve this problem you must add a space in the end of the second line.

query = "SELECT u from User u"
      + "INNER JOIN ON g.grp_id Group g = u.grp_id "
      + "and grp.grp_name = ?1";

Aucun commentaire :

Enregistrer un commentaire