Soft-delete issue

I am encountering an issue with the SoftDelete annotation in my entity class. It forces eager loading, which is causing performance issues.

Consider the following class:

@Entity
@Data
@SoftDelete
public class OrgUnit {

    @Id
    @GeneratedValue
    private UUID id;

    private String name;

    @NotFound
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    private OrgUnit parent;
}

When I try to read a leaf node by its ID, it reads all the parent nodes recursively. This happens because SoftDelete forces eager loading, even though I have specified FetchType.LAZY for the parent association.

According to the documentation, NotFound and FetchType.LAZY cannot be used together for ManyToOne and OneToOne associations. They are forced to use eager fetching.

OrgUnit.parent uses both @NotFound and FetchType.LAZY.
@ManyToOne and @OneToOne associations mapped with @NotFound are forced to EAGER fetching.

How can I use SoftDelete with lazy loading? Any help would be appreciated.

This blocks us from using the new soft-delete feature. Any help is appreciated.

You cannot use @SoftDelete and expect FetchType.LAZY to be respected, exactly as with @NotFound, as you can read in our user guide:

@ManyToOne and @OneToOne associations annotated with @NotFound are always fetched eagerly even if the fetch strategy is set to FetchType.LAZY.

Since we cannot rely on the foreign key constraint to ensure the existence (or non-existence) of an associated entity, we need to explicitly access the data with the soft-delete filter to understand the association’s state on the database. That is the main and only downside of this feature, but it cannot work correctly without it.

As stated in this documentation, it seems impossible to use both soft delete and lazy loading together. I’m searching for a workaround because this constraint makes the feature nearly unusable. This is especially challenging since we have recursive entities (with parentId) and numerous manyToOne associations to various type entities (ex: GenderType, City).