Data and writes

Soft delete

The base class brings soft delete; hand-written SQL must add the condition; the column is NOT NULL DEFAULT 0.

Default behaviour

The entity base class BaseDO.isDeleted already carries the soft-delete marker, so framework-generated statements append is_deleted = 0 automatically.

Three hard rules

  • A query object must not declare an isDeleted field: the framework ignores it anyway, so it only misleads readers.
  • Hand-written XML is not covered by the automatic append; add is_deleted = 0 yourself.
  • The column must be NOT NULL DEFAULT 0 — allowing NULL makes a check like is_deleted != 1 miss a whole batch of rows.

Warning: a hand-written query missing this condition is the most common and most invisible data leak: small test data hides it, and in production it shows up as "someone saw data they should not".

When to delete physically

Tables with a natural expiry, such as verification codes and temporary tokens, may be deleted physically. Business master data is always soft deleted. The test is simple: will you need to trace it when something goes wrong?

Last updated 2026-10-09Edit this page →