O'Reilly logo

Spring Persistence with Hibernate by Ahmad Seddighi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Bulk updates and bulk deletes with HQL

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 update and delete keywords with the set and 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required