When an entity is annotated with @SoftDelete, how to retrieve all the records?

Hi all,
I’m pretty new here.
I need to use @SoftDelete annotation to facilitate sofe delete operation with hibernate 6.4.
When I use @SoftDelete all the queries automatically be applied restriction to retrieve only not deleted records. I used JpaSpecification criterias and simple queries and native queries as well. But still cannot retrive all the records (deleted and not deleted all).

How can I achive this?
Is there any method that I could override the @SoftDelete function? Addition of “and deleted=false” restriction bypass?
Any clue would be greate!

Hello, there’s no way of getting around the @SoftDelete filters by using Hibernate APIs and that’s by design. You will have to use a native SQL query if you want to read soft-deleted data.

1 Like

Thanks @mbladel. It works.