Delete a tenant with all it's data

Hi,

I have a multitenant application, so the entities used by a particular tenant are based on a class

@Getter
@Setter
@JmixEntity
@MappedSuperclass
public abstract class TenantBasedEntity implements TenantEntity {
    @SystemLevel
    @Column(name = "TENANT_ID")
    @TenantId
    protected String tenantId;
}

What is the best way to delete a tenant and all it’s entities? Is it possible to do it using JPA cascade remove or something like that?

No, you have to remove each entity explicitly, considering dependencies between them.

1 Like