mailwal

Official soft delete feature

Thorben

Hey,

Do you know that Hibernate provides an official soft delete feature?

It was introduced in version 6.4 and is a great replacement for the custom solutions we had to build in the past.

(Soft delete = You deactivate/hide records instead of deleting them)

It now only takes a simple @SoftDelete annotation, and Hibernate handles the rest.

After you add this annotation, Hibernate automatically tracks if a record is active or deleted and excludes all deleted records from query results.

Here is an article that explains Hibernate's new soft delete feature with all its configuration options in more detail.

(And I also explain how to implement a soft delete when using Hibernate <=6.3)

Speak soon,

Thorben

  1. Check out the latest tutorials on the blog.
    Stay up to date with the latest releases and features in the Java persistence world. Read the blog.

  2. Watch my tutorials on YouTube.
    You prefer videos over written content? Then my YouTube channel is the right place for you.

  3. Get my Hibernate Tips ebook.
    The ebook is packed with ready-to-use solutions to help you solve your next Hibernate problem even quicker. Get it here.

  4. Join the Persistence Hub.
    The Persistence Hub teaches you everything you need to know on your journey to becoming a Java persistence expert. Get access to video courses, Expert Sessions with amazing guests, monthly Java Persistence News, and more. Become a member.

Thorben Janssen, Elser Bruch 63, 33106, Paderborn, Germany