Skip to content

Commit e61b5f0

Browse files
committed
HHH-17325 - @softdelete with timestamp
1 parent b6990d2 commit e61b5f0

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

documentation/src/main/asciidoc/userguide/chapters/domain/soft_delete.adoc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ Soft delete support is defined by 3 main parts -
2020
[[soft-delete-type]]
2121
==== Strategy - SoftDeleteType
2222

23-
Given truth values, there are 2 valid ways to interpret the values stored in the database. This
23+
Hibernate supports timestamp and truth-based soft delete strategies, configured by the `strategy` attribute of the `@SoftDelete` annotation.
24+
25+
The TIMESTAMP strategy tracks the timestamp at which the row was deleted.
26+
27+
For truth-based strategies, there are 2 valid ways to interpret the values stored in the database. This
2428
interpretation is defined by the SoftDeleteType enumeration and can be configured per-usage using
2529
`@SoftDelete(..., strategy=ACTIVE)` or `@SoftDelete(..., strategy=DELETED)` -
2630

@@ -43,6 +47,8 @@ ACTIVE::
4347
The default column name is `active`.
4448
DELETED::
4549
The default column name is `deleted`.
50+
TIMESTAMP::
51+
The default column name is `deleted`.
4652

4753
See <<soft-delete-basic-example>> for an example of customizing the column name.
4854

@@ -52,8 +58,11 @@ Depending on the conversion type, an appropriate check constraint may be applied
5258
[[soft-delete-conversion]]
5359
==== Indicator conversion
5460

55-
The conversion is defined using a Jakarta Persistence <<basic-jpa-convert,AttributeConverter>>. The domain-type is always
56-
`boolean`. The relational-type can be any type, as defined by the converter; generally `BOOLEAN`, `BIT`, `INTEGER` or `CHAR`.
61+
When using a truth-based strategy, a conversion can be specified using a Jakarta Persistence <<basic-jpa-convert,AttributeConverter>>.
62+
The domain-type is always `boolean`.
63+
The relational-type can be any type, as defined by the converter; generally `BOOLEAN`, `BIT`, `INTEGER` or `CHAR`.
64+
65+
NOTE: It is considered an error to specify a conversion with the TIMESTAMP strategy and an exception will be thrown.
5766

5867
An explicit conversion can be specified using `@SoftDelete#converter`. See <<soft-delete-basic-example>>
5968
for an example of specifying an explicit conversion. Explicit conversions can specify a custom converter or leverage

migration-guide.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ For example, this property declaration is no longer allowed:
124124
String isDefault();
125125
----
126126

127+
[[soft-delete-timestamp]]
128+
== @SoftDelete with TIMESTAMP
129+
130+
Soft-delete now supports the strategy of tracking the timestamp at which the soft-delete occurred,
131+
in addition to the previous truth-based strategies.
132+
See the link:{user-guide-url}#soft-delete[User Guide] for details.
133+
134+
127135
[[envers-rev-types]]
128136
== Hibernate Envers and custom revision entities
129137

0 commit comments

Comments
 (0)