You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/src/main/asciidoc/userguide/chapters/domain/soft_delete.adoc
+23-35Lines changed: 23 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,16 +23,20 @@ Soft delete support is defined by 3 main parts -
23
23
24
24
1. The <<soft-delete-column,column>> which contains the indicator.
25
25
2. A <<soft-delete-conversion,conversion>> from `Boolean` indicator value to the proper database type
26
-
3. Whether to <<soft-delete-reverse,reverse>> the indicator values, tracking active/inactive instead
26
+
3. A <<soft-delete-type,strategy>> for interpreting the stored indicator values.
27
27
28
28
29
29
[[soft-delete-column]]
30
30
==== Indicator column
31
31
32
32
The column where the indicator value is stored is defined using `@SoftDelete#columnName` attribute.
33
33
34
-
When using <<soft-delete-reverse,reversed>> mappings, the column name defaults to `active`; otherwise, it
35
-
defaults to the name `deleted`.
34
+
The default column name depends on the <<soft-delete-type,strategy>> being used -
35
+
36
+
ACTIVE::
37
+
The default column name is `active`.
38
+
DELETED::
39
+
The default column name is `deleted`.
36
40
37
41
See <<soft-delete-basic-example>> for an example of customizing the column name.
38
42
@@ -42,11 +46,11 @@ Depending on the conversion type, an appropriate check constraint may be applied
42
46
[[soft-delete-conversion]]
43
47
==== Indicator conversion
44
48
45
-
The conversion is defined using a JPA <<basic-jpa-convert,AttributeConverter>>. The "domaintype" is always
46
-
`boolean`. The "relationaltype" can be any type, as defined by the converter; generally `BOOLEAN`, `BIT`, `INTEGER` or `CHAR`.
49
+
The conversion is defined using a Jakarta Persistence <<basic-jpa-convert,AttributeConverter>>. The domain-type is always
50
+
`boolean`. The relational-type can be any type, as defined by the converter; generally `BOOLEAN`, `BIT`, `INTEGER` or `CHAR`.
47
51
48
52
An explicit conversion can be specified using `@SoftDelete#converter`. See <<soft-delete-basic-example>>
49
-
for an example of specifying an explicit conversion. Explicit conversions can specify a custom converter or leverage the 3
53
+
for an example of specifying an explicit conversion. Explicit conversions can specify a custom converter or leverage
50
54
Hibernate-provided converters for the 3 most common cases -
51
55
52
56
`NumericBooleanConverter`:: Defines conversion using `0` for `false` and `1` for `true`
@@ -60,6 +64,8 @@ boolean (and bit):: the underlying type is boolean / bit and no conversion is ap
60
64
numeric:: the underlying type is integer and values are converted according to `NumericBooleanConverter`
61
65
character:: the underlying type is char and values are converted according to `TrueFalseConverter`
62
66
67
+
IMPORTANT: The converter should simply convert the `true` and `false`, irrespective of the <<soft-delete-type,strategy>> used. Hibernate will handle applying the strategy.
68
+
63
69
64
70
[[soft-delete-entity]]
65
71
==== Entity soft delete
@@ -133,35 +139,17 @@ The `@SoftDelete` annotation may also be placed at the package level, in which c
133
139
entities and collections defined within the package.
134
140
135
141
136
-
[[soft-delete-reverse]]
137
-
==== Reversed soft delete
142
+
[[soft-delete-type]]
143
+
==== Strategy - SoftDeleteType
138
144
139
-
A common requirement in applications using soft delete is to track rows which are active as opposed to removed,
0 commit comments