2

I have two relations in my class:

@OneToOne(mappedBy = "poi", cascade = { CascadeType.ALL })
@CascadeOnDelete
protected PoiDescription description;

@OneToMany(mappedBy = "poi", cascade = { CascadeType.ALL })
@CascadeOnDelete
protected List<PoiAdditional> additionals = new ArrayList<>();

In my generated DDL (for postgres) I becomes:

ALTER TABLE POI_DESCRIPTION ADD CONSTRAINT FK_POI_DESCRIPTION_POI_ID FOREIGN KEY (POI_ID) REFERENCES POI (ID)
ALTER TABLE POI_ADDITIONAL ADD CONSTRAINT FK_POI_ADDITIONAL_POI_ID FOREIGN KEY (POI_ID) REFERENCES POI (ID) ON DELETE CASCADE

Why the relation @OneToMany has the statement "ON DELETE CASCADE" and the relation @OneToOne has not?

Thanks in advance

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
Daniel
  • 21
  • 1

1 Answers1

0

The current DDL generation code in EclipseLink seems to be check for the @CascadeOnDelete on the @OneToOne source, not the mappedBy. But I think you are correct, it should be checking the mapping using the mappedBy.

Please log a bug.

As a workaround you should be able to add it to both sides.

James
  • 17,965
  • 11
  • 91
  • 146
  • Hi James, thank you for your answer. But your idea, to use both statements, worked not! You can see this in the generated DDL code. I think it's a bug, too. – Daniel Jul 26 '13 at 09:23