Orphan removal with @Where clause

105 views Asked by At

I have a hierarchical structure. Some children are hidden so I have @Where clause:

@OneToMany(fetch = FetchType.LAZY, orphanRemoval = true)
@org.hibernate.annotations.Where(clause = "hidden=false")
private List<Element> children;

But when I want to remove the whole sub-structure (including hidden children) by deleting parent node, hibernate seems to skip hidden children and i get db exception:

org.postgresql.util.PSQLException: ERROR: update or delete on table "xxx" violates foreign key constraint "yyy_yyy_id_fkey" on table "zzz"

Does hibernate have some method of dealing with it?

0

There are 0 answers