eclipse-ee4j / eclipse-ee4j/eclipselink
Inconsistent DDL with @CascadeOnDelete
- Dominant language
- Java
- Stars
- 246
- Forks
- 202
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 14
Description
I'm running into this issue where @CascadeOnDelete sometimes does not generate the expected DDL.
Here is the code to reproduce is [here]( https://github.com/maald/bug)
The code is very simple. I have 2 packages with 3 entities in each. The entity structure in both packages is identical (parent entity and two child entities). The bug seems to occur in one package or the other but not both at the same time. The choice seems random.
Entity Model:
package 1: Car <--M-----1--> Person <--1---M--> Pet
package 2: Address <--M-----1--> Customer <--1---M--> Phone
Both Person and Customer use @CascadeOnDelete
The generated DDL with the bug:
[createDDL.txt](https://github.com/eclipse-ee4j/eclipselink/files/3243279/createDDL.txt)
--------------------------------------------------------------------------
CREATE TABLE Persons ...
CREATE TABLE Pets ...
CREATE TABLE Cars ...
CREATE TABLE Customers ...
CREATE TABLE Phones ...
CREATE TABLE Addresses ...
ALTER TABLE Pets ... FOREIGN KEY ... Persons (ID)
ALTER TABLE Cars ... FOREIGN KEY ... Persons (ID) ON DELETE CASCADE
ALTER TABLE Phones ... FOREIGN KEY .. Customers (ID) ON DELETE CASCADE
ALTER TABLE Addresses ... FOREIGN KEY ... Customers (ID) ON DELETE CASCADE
--------------------------------------------------------------------------
At least one of the generated DDL for the FK will not have the correct DDL. It also occurred with a single package (3 entities for the whole project) too but less often.
Environment:
- EclipseLink JPA 2.7.4
- MariaDB: mariadb-10.3.15-winx64
- JDK:
java version "11.0.2" 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)
Contributor guide
Research direction
Start with the linked reproducer and createDDL.txt, then compare the generated foreign-key statements for Person, Customer, and their child entities. Repeat the generation to check whether the affected package changes, and verify that each relevant foreign key for @CascadeOnDelete includes ON DELETE CASCADE.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mariadb
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100