We're updating the issue view to help you get more done. 

Hibernate @SQLDelete Not consistent When used On A Collection

Description

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

Environment

Linux
JDK1.8.X
MySQL or MariaDB

Status

Assignee

Unassigned

Reporter

Kerry Billingham

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.2.17

Priority

Major