I am getting the following error when I try to implement my query
below:
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token
My query is within a Spring data PersonRepository
that extends CrudRepository
Query:
@Modifying
@Transactional
@Query("DELETE (entity) FROM Person entity WHERE entity.id = :id")
List<Person> deleteFromPersonWithId(@Param("id") String id);
What is the error in my syntax?
You don't have a right syntax of DELETE query, it should look like this.
DELETE FROM Person entity WHERE entity.id = :id
By the way there is a delete method which does exactly what you want in the CrudRepository
itself. So no need to duplicate it.