I am trying to update a record in the database and I getting this error
org.springframework.orm.hibernate4.HibernateQueryException: Not supported for DML operations [UPDATE com.xxx.models.User u set u.notifiable = true WHERE u.emailAccess = :emailAccess AND u.isAdmin = false]; nested exception is org.hibernate.hql.internal.QueryExecutionRequestException: Not supported for DML operations [UPDATE com.xxx.models.User u set u.notifiable = true WHERE u.emailAccess = :emailAccess AND u.isAdmin = false]
This is my hql attempt
@Modifying
public User updateUser(String emailAccess) {
String hql = "UPDATE User u set u.notifiable = true WHERE u.emailAccess = :emailAccess AND u.isAdmin = false";
return (User) _sessionFactory.getCurrentSession().createQuery(hql).setParameter("emailAccess", emailAccess).list();
}
After researching, I added the @Modifying annotation to the top of the method but the error still persists. Please what could be wrong?