Search code examples
javasqlhibernatespring-mvchql

"Not supported for DML operations" with simple UPDATE query


I'm getting the error Not supported for DML operations when I use the following HQL...

@Query("UPDATE WorkstationEntity w SET w.lastActivity = :timestamp WHERE w.uuid = :uuid")
void updateLastActivity(@Param("uuid") String uuid, @Param("timestamp") Timestamp timestamp);

What could be causing the issue? It doesn't seem to be a common error given the few results I've found in Google.


Solution

  • 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();