I have an error on the code below, I need to update a series of article with a native query in spring boot to do it I use the code below, however when it executes the code I have the following error, how can I do to fix it ? The error is on the "Sconto" field.
Error Native Query:
[nio-8081-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : Incorrect syntax near '='.
2022-02-25 09:51:59.045 INFO 29122 --- [nio-8081-exec-1] : Errore importazione METEL: org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Native Query Code Spring Boot:
@Transactional
@Modifying
@Query(value = "update Articolo set Prezzo=(PrezzoListino-((PrezzoListino/100) * =:Sconto )) where Importato=:Importato and CodMarca=:CodMarca and FamigliaDiSconto=:FamigliaDiSconto ", nativeQuery = true)
List<Articolo> updateArticoloMetelScontoFirst(@Param("Sconto") Double Sconto, @Param("CodMarca") String CodMarca, @Param("Importato") String Importato, @Param("FamigliaDiSconto") String FamigliaDiSconto);
Error is pretty descriptive Incorrect syntax near '='
. In query problem is here
...set Prezzo=(PrezzoListino-((PrezzoListino/100) * =:Sconto ))...
Remove unwanted =
before :Sconto
...set Prezzo=(PrezzoListino-((PrezzoListino/100) * :Sconto ))...