Bulk delete doesn't cascade delete on join table

Description

HQL delete doesn't cascade delete on join table.

Person bob = new Person();
bob.setId(1l);
bob.setFirstname("bob");
getCurrentSession().save(bob);

Cat felix = new Cat();
felix.setId(1l);
felix.setName("felix");
Set<Person> owners = new HashSet<Person>();
owners.add(bob);
felix.setOwners(owners);
getCurrentSession().save(felix);

Query query = getCurrentSession().createQuery("delete com.company.product.domain.Cat c where c.id=aram_id)");
query.setParameter("param_id", 1l);
return query.executeUpdate();

insert into PERSON (FIRSTNAME, ID) values (?, ?)
insert into CAT (NAME, ID) values (?, ?)
insert into CAT_PERSON (ID_CAT, ID_PERSON) values (?, ?)
delete from CAT where ID=?

-> ConstraintViolationException: could not execute statement
violation of FOREIGN KEY constraint "FK_3QS4XQHEUL1KIQILV53S1F0GB" on table "CAT_PERSON"

Note that if Cat extends Animal with joined-subclass mapping everything is OK.

Environment

Hibernate 4.2.5.Final, Firebird, Tomcat 7, jdk 1.7, Windows 7

Status

Assignee

Brett Meyer

Reporter

Aurelien DROUARD

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.2.5

Priority

Major
Configure