Question

The following query that is working perfectly fine when I am using hibernate as the JPA provider is not working with OpenJPA:

entityManager.createQuery(
        "select ord from Order ord " +
        "where symbol = :symbol")
    .setParameter("symbol", symbol)
    .getResultList();

The error returned is

java.lang.IllegalArgumentException: Invalid unbound variable "symbol" in query

Am I doing something wrong in my query that OpenJPA does not like?

Était-ce utile?

La solution

I believe you want to change:"where symbol = :symbol" to :

 "where ord.symbol = :symbol"

Or, use positional parameters:

"where ord.symbol = ?1"

  .setParameter(1, symbol)

Hope that helps.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top