Hibernate: how to fetch only not-logically deleted objects

前端 未结 1 459
轮回少年
轮回少年 2020-12-20 20:35

Nearly every table in our database has a FK to the Auditing table which logs created, updated and deleted status (date and username).

We mapped the auditing table to

1条回答
  •  离开以前
    2020-12-20 20:53

    IMO, the easiest way to implement a soft-delete would be to add a flag in your entities and to use:

    • the @SQLDelete annotation to override the default Hibernate delete (and perform an update of the flag)
    • the @Where (or @Filters?) annotation on your entities and associations to filter the deleted entities

    Not sure how this can fit with your Auditing table though. Some further exploration and testing are required.

    Resources

    • Soft deletes using Hibernate annotations

    0 讨论(0)
提交回复
热议问题