I have a problem. I want to make a JPQL
, and make a kind of filter that lists me the type of merchandise that have similarity with the name specified by the user.
@Override
public List<TblStock> findByName(String nombre) {
TypedQuery<TblStock> q = getEntityManager().createQuery("SELECT p FROM TblStock p where p.tipoMercancia like '%:nombre%' ", TblStock.class);
q.setParameter("nombre", tipoMercancia);
return q.getResultList();
}
When making this query, I get the following error:
java.lang.IllegalArgumentException: You have attempted to set a parameter value using a name of typeMercance that does not exist in the query string SELECT p FROM TblStock p where p.typeMercance like '%: typeMercance%'.
Clearly you are not accepting the nombre
parameter, but I do not know how else you could do a query with LiKE
.
I appreciate any contribution, thank you very much.