i need to translate some MySQL code to a JPA named query
example
select * from movies where title like '%matrix%'
would my gues it would
@NamedQuery(name = "Movies.findMoviePart", query = "SELECT c FROM Movies c where c.title LIKE '% :title %'")}) be but it has some errors
org.springframework.dao.InvalidDataAccessApiUsageException: org.hibernate.QueryParameterException: could not locate named parameter [title]; nested exception is java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [title]
code in dao impl
@Override public List getAllPartMovie(String title) {
TypedQuery query = entityManager.createNamedQuery("Movies.findMoviePart", Movies.class); query.setParameter("title", title); try { return query.getResultList(); } catch (NoResultException ex) { // geen record gevonden return null; }
tanks for your help guys