| When mapping entities with a One-to-Many or Many-to-Many relationship a join table is used either an existing one or generated by Hibernate. By default when a relationship between two specific entities is removed the corresponding join table record is hard-deleted. In some instances hard-deletion of the join table relationship is not desired but Hibernate can be co-erced into soft-deleting relationships with the use of the @SQLDelete annotation. This is satisfactory until ALL members of a collection are to be removed. What happens in this instance is that Hibernate no longer honours the @SQLDelete annotation and performs a hard-delete on join table records. While there appears to be no explicit statement in the JPA specification of how join table records should be deleted the above behaviour appears to be inconsistent in that what 'delete' operation that actually occurs i.e. it is dependent upon on what remains within the collection. An example project is here: soft-delete-joins |