Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] remove childs in one-to-many

Title: remove childs in one-to-many

Hi folks,

we encounter a problem with EL. We migrate from Kodo where different things worked which do not in EL.

-       In a one-to-many relation i want to remove a child from the collection in the parent:

-       Department dept = em.find(Department.class, 30);

-       Employee emp = dept.getEmployees.getFirst();

-       dept.getEmployees().remove(emp);

-       emp.setDepartment(null);

After some further steps in the transaction there is a flush, and EL tries to update emp, to set the department foreign key to null, which causes a foreign key constraint violation.

This looks like an error because this behaviour does not occur at all relations with the same mapping.

We think that the code is correct in the sense that the OR-Mapper has to respect the need to remove the relation on the Java object in order to be enabled to be garbage collected.

Mapping from the parent side is configured with private-owned and cascade-all.

Mapping back from the child to the parent is configured with cascade-merge, cascade-persist

We use EL 1.2

Any ideas or hints would be appreciated.

Regards, Markus


Back to the top