"Not supported for DML operations" with simple UPDATE query

Check the post hibernate hql ERROR: Not supported for DML operations in the hibernate users forum.

Most likely you called

querySt.list();

for your UPDATE query. Instead you should call

querySt.executeUpdate();

I was also having the same problem with annotations.After searching and doing some tricks I was able to solve it. There are some below steps which you need to verify while using DML operation with JPA.

  1. Use anotation @Modifying(org.springframework.data.jpa.repository.Modifying) and @Transactional(org.springframework.transaction.annotation.Transactional) on required method.

  2. Use void as return type of method.

e.g:-

@Modifying
@Query("UPDATE ProcedureDTO o SET o.isSelectedByUser =?1")
@Transactional
public void getListOfProcedureBasedOnSelection(Boolean isSelected);```