Package org.hibernate.annotations
Annotation Interface SoftDelete
@Target({PACKAGE,TYPE,FIELD,METHOD,ANNOTATION_TYPE})@Retention(RUNTIME)@Documented@Incubatingpublic @interfaceSoftDelete
Describes a soft-delete indicator mapping. Soft deletes handle "deletions" from a database table by setting a column in the table to indicate deletion. May be defined at various levels
- PACKAGE, where it applies to all mappings defined in the package, unless defined more specifically.
- TYPE, where it applies to an entity hierarchy. The annotation must be defined on the root of the hierarchy and affects to the hierarchy as a whole. The soft-delete column is assumed to be on the hierarchy's root table.
- FIELD /METHOD, where it applies to the rows of an
ElementCollectionorManyToManytable. - ANNOTATION_TYPE on another annotation defined according to the previous targets.
- Since:
- 6.4
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceOptional Element Summary
Optional ElementsModifier and TypeOptional ElementDescription(Optional) The name of the column.(Optional) A comment to be applied to the column.Class<? extendsAttributeConverter<Boolean,?>> (Optional) Conversion to apply to determine the appropriate value to store in the database.(Optional) The SQL fragment that is used when generating the DDL for the column.The strategy to use for storing/reading values to/from the database.
Element Details
columnName
String columnName(Optional) The name of the column. Default depends on thestrategy being used.- Default:
- ""
options
String options(Optional) The SQL fragment that is used when generating the DDL for the column.The DDL must be written in the native SQL dialect of the target database (it is not portable across databases).
- Since:
- 7.0
- Default:
- ""
comment
String comment(Optional) A comment to be applied to the column.- Since:
- 7.0
- Default:
- ""
strategy
SoftDeleteType strategyThe strategy to use for storing/reading values to/from the database. The strategy also affects the defaultcolumn name - seeSoftDeleteType.getDefaultColumnName().- Default:
- DELETED
converter
Class<? extendsAttributeConverter<Boolean,?>> converter(Optional) Conversion to apply to determine the appropriate value to store in the database. The "domain representation" can be:true- Indicates that the row is considered deleted
false- Indicates that the row is considered NOT deleted
- API Note:
- Only valid whenstrategy() isSoftDeleteType.DELETED orSoftDeleteType.ACTIVE. Will lead to aUnsupportedMappingException when combined withSoftDeleteType.TIMESTAMP.
- Implementation Specification:
- The specified converter should never return
null
- Default:
- org.hibernate.annotations.SoftDelete.UnspecifiedConversion.class