0

Tengo el siguiente query:

@Query(value = "SELECT php.producto.idProducto AS id FROM PartnerHasProducto php WHERE php.producto.idProducto IN :idsProductos")
ArrayList<Long> haveProveedor(@Param("idsProductos") ArrayList<Long> idsProductos);

y al ejecutarlo me marca este error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
ERROR: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet => could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet

Seguí este ejemplo ejemplo, y nose que es lo que este mal

Actualización y Solución:

El error es por que la variable 'idsProductos', llega en null

2
  • Eso no es una nativeQuery (SQL), es JPQL el 9 mar. 2020 a las 19:14
  • Cierto! ya corregí el 9 mar. 2020 a las 19:19

1 respuesta 1

1

Esa query no es native query.

Deberías cambiar

@Query(value = "SELECT php.producto.idProducto AS id FROM PartnerHasProducto php WHERE php.producto.idProducto IN :idsProductos")

por

@Query(value = "SELECT NT.idProducto AS id FROM NOMBRE_TABLA NT WHERE N.idProducto IN :idsProductos")
1
  • Es lo que ya tengo, no veo la diferencia el 9 mar. 2020 a las 19:24

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.