| I have several Entities which have a reference to the same instance of another Entity-Object like so:
@Data
@Entity
@OnDelete(action = OnDeleteAction.CASCADE)
class A {
@Id
private Long id;
}
@Data
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
abstract class B {
@Id
private Long id;
@OnDelete(action = OnDeleteAction.CASCADE)
@ManyToOne(fetch = FetchType.EAGER, optional = false, cascade = CascadeType.REMOVE)
private A a;
}
@Data
@Entity
class C extends B {
}
@Data
@Entity
class D extends B {
}
My problem is I just want to delete cascade the instance `A`. The number of Entities referencing A is not known upfront (hence the class is abstract). The DDL generated of the concrete classes `C` and `D` does not contain the `OnDelete` action anymore, so I had to work around using `@JoinColumn` together with `@ForeignKey` lke so: @JoinColumn(foreignKey = @ForeignKey(foreignKeyDefinition="FOREIGN KEY (trance_id) REFERENCES m_trace(id) ON DELETE CASCADE")) |