-1

i have this method:

public List<String> getTipoConsensoRichiesto(String tipologiaProdotto) {
    return entityManager.createNativeQuery("Select TIPO_CONSENSO_RICHIESTO from  PRIVACY_CONFIGURAZIONE WHERE TIPOLOGIA_PRODOTTO = :tipologiaProdotto ")
        .setParameter("tipologiaProdotto",tipologiaProdotto)
        .getResultList();
}

when i execute the query i have the following problem:

Internal Exception: java.sql.SQLException: Parametro IN o OUT mancante nell'indice:: 1 Error Code: 17041 Call: Select TIPO_CONSENSO_RICHIESTO from PRIVACY_CONFIGURAZIONE WHERE TIPOLOGIA_PRODOTTO = :tipologiaProdotto Query: DataReadQuery(sql="Select TIPO_CONSENSO_RICHIESTO from PRIVACY_CONFIGURAZIONE WHERE TIPOLOGIA_PRODOTTO = :tipologiaProdotto ")

How i can solve? Thank you

veljkost
  • 1,748
  • 21
  • 25
Filomena
  • 29
  • 1
  • 9
  • 1
    Named parameters are not mandatory to be supported in NATIVE queries in JPA, as per the JPA spec. Use numbered –  Jan 18 '18 at 13:57
  • see https://stackoverflow.com/questions/3144235/jpa-hibernate-native-queries-do-not-recognize-parameters#3145275 – Laurent B Jan 18 '18 at 13:58

1 Answers1

0

Try using:

return entityManager.createNativeQuery("Select TIPO_CONSENSO_RICHIESTO from PRIVACY_CONFIGURAZIONE WHERE TIPOLOGIA_PRODOTTO = ?1 ").setParameter(1,tipologiaProdotto).getResultList();

Andre Albert
  • 1,386
  • 8
  • 17