Using HQL, you can also update or delete a set of persisted objects. The syntax of HQL for update and delete operations is similar to SQL. HQL uses the
delete keywords with the
where clause to update or delete rows that satisfy a set of criteria. For instance, to modify the name of a course, you can use the following HQL expression:
String updateHql = "update Course set name = :newName where name = :name";
The usage of the
set keyword in HQL is similar to the usage of
set in SQL. It determines new values for object's properties. You can optionally use the
where clause to restrict the object being updated.
Similarly, you can use the
delete query with an optional
where clause to remove a ...