@SoftDelete with Relationships to retrive deleted records

I need to implement SoftDelete functionality in Spring boot 3.
Here, I need to achive the below.
For example let’s say I have Product and Order tables(Entities) which has OneToMany relationship between Oder and Product.

  1. Delete records in soft manner both Product and Order.
  2. Retrive all records (with deleted records as well), both Product and Order.
  3. Retrieve all Order records with Product objects even though the Product is soft deleted.

How can I implement this? I did a lot of googling, ChatGPT, and gemini as well.
Didn’t find a workable solution.

Hibernate has introduced native soft-delete support, but the only way to retrieve entities which have been deleted is to use native queries.

You could implement your own soft-delete logic, i.e. updating a boolean field that sets the deleted flag instead of actually removing entities, and having Hibernate @FilterDefs that filter out entities only conditionally, when the filter is enabled in the session.