I have the following code:
In the entity Article
I have the following @NamedQuery
@NamedQuery(name="Article.aumentapreu",
query="UPDATE Article a SET a.preu=a.preu*:quantitat")
And in manager class article:
/**
* Incrementa el preu de tots els articles de la base de dades en un percentatge determinat
* @param percentantge tant per cent (%) d'increment
*/
public void incrementarPreu(float percentantge){
//TODO completar el metode
Query ap = em.createNamedQuery("Article.aumentapreu");
ap.setParameter("quantitat", percentantge);
em.getTransaction().begin();
ap.executeUpdate();
em.getTransaction().commit();
}
The problem I have is that it gives me an error because it tells me that the query only supports input parameters between the WHERE or HAVING clauses.
Any idea how to solve it?