Delete an element doesn't delete automatically rows in table of a "map" mapping

Description

Delete an element doesn't delete automatically rows in table of a "map" mapping :

--------------
Java test :
--------------
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);

felix.setMap(new HashMap<Integer, Integer>());
felix.getMap().put(1, 10);
felix.getMap().put(2, 10);
felix.getMap().put(3, 15);
felix.getMap().put(4, 20);

getCurrentSession().save(felix);

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

--------------
Generated SQL:
--------------
insert into PERSON (FIRSTNAME, ID) values (?, ?)
insert into CAT (NAME, ID) values (?, ?)
insert into CAT_PERSON (ID_CAT, ID_PERSON) values (?, ?)
insert into MAP (CAT_KEY, MAP_KEY, MAP_VALUE) values (?, ?, ?)
insert into MAP (CAT_KEY, MAP_KEY, MAP_VALUE) values (?, ?, ?)
insert into MAP (CAT_KEY, MAP_KEY, MAP_VALUE) values (?, ?, ?)
insert into MAP (CAT_KEY, MAP_KEY, MAP_VALUE) values (?, ?, ?)
delete from CAT_PERSON where (ID_CAT) in (select ID from CAT where ID=?)
delete from CAT where ID=?

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

Attachments

4

Activity

Show:

Brett MeyerNovember 18, 2013 at 10:46 PM

We're swamped, but I'll take a look when I can. A pull request would get it in faster

Aurelien DROUARDNovember 4, 2013 at 9:53 AM

Hello . Is there any chance that 4.2.8 version include a fix for this problem ?

Details

Assignee

Reporter

Components

Priority

Created October 9, 2013 at 7:41 AM
Updated May 30, 2014 at 3:26 PM