سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top