Foreign key fails on deletion because Hibernate doesn't remove association first

I have a problem with constraint fail when I cascade-delete entity which references another entity.

I’m using Hibernate as my JPA Provider.

Domain model:

ERD

  • Every Zone can have more Actions, but Actions are not shared between Zones (OneToMany).
  • TeleportAction (one possible kind of Action) contains a set of Zones as targets. Every TeleportAction can have more Zones as targets and Zones and they can be used by multiple TeleportActions (ManyToMany).

How deletion works

  1. I call ZoneManager.deleteZone(zone)
    1. ZoneManager first loops through all Zones and their TeleportActions and removes deleted Zone from their targets.
    2. After that ZoneManager removes given Zone from it’s list of Zones
  2. Then I delete Zone from DB with Hibernate via session.delete(zone). This operation propagates to Actions.

Error which I get

Hibernate: /* delete cz.iwitrag.greencore.gameplay.zones.Zone */ delete from gcore_Zone where id=?
[org.hibernate.engine.jdbc.spi.SqlExceptionHelper] SQL Error: 1451, SQLState: 23000
[org.hibernate.engine.jdbc.spi.SqlExceptionHelper] Cannot delete or update a parent row: a foreign key constraint fails (`309145_mysql_db`.`gcore_tpaction_targetzones`, CONSTRAINT `FK4rvpdg8xjyt6lk5281jbi78c5` FOREIGN KEY (`targetZone_id`) REFERENCES `gcore_Zone` (`id`))
[org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl] HHH000010: On release of batch it still contained JDBC statements
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
...

This error is caused because when I delete Zone, it is still target of some TeleportActions.

Even though I deleted this Zone from TeleportAction's targets in business code before calling session.delete(zone), Hibernate doesn’t acknowledge it and doesn’t remove this Zone from ManyToMany association.

Entities

@Entity
public class Zone {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", updatable = false, nullable = false)
    private Long id;

    @OneToMany(fetch = FetchType.EAGER, orphanRemoval = true)
    @Cascade(CascadeType.ALL)
    @OrderColumn(name = "list_id")
    @JoinColumn(name = "zone_id")
    private List<Action> actions = new ArrayList<>();
...
}
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "actionType")
public abstract class Action {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", updatable = false, nullable = false)
    private Long id;
...
}
@Entity
@DiscriminatorValue("tp")
public class TeleportAction extends Action {

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "tpaction_targetzones", joinColumns = @JoinColumn(name="tpAction_id"), inverseJoinColumns = @JoinColumn(name="targetZone_id"))
    private Set<Zone> targets = new HashSet<>();
...
}

Question

How can I force Hibernate to automatically delete removed Zone from table tpaction_targetzones before it actually deletes Zone from database to avoid foreign key constraint error?