Generate 'on delete cascade' and 'on update cascade' with hbm2ddl tool for @ElementCollection generated foreign key

Description

The hbm2ddl tool generates the foreign key for an @ElementCollection, when it is configured to run. According to the JPA wikibooks (http://en.wikibooks.org/wiki/Java_Persistence/ElementCollection): "There is no cascade option on an ElementCollection, the target objects are always persisted, merged, removed with their parent." Which, of course, sounds utterly sensible, because @ElementCollection contains Basic / Embeddable value types that do not have their own lifecycle. However, this is currently not happening in Hibernate's JPA implementation, as reported in HHH-5529.

As a workaround, can the hbm2ddl tool please add 'on delete cascade' and 'on update cascade' clauses to the generated foreign key?

In our use case, we use MySQL with InnoDB engine as production database and use hsqldb as database for integration tests. For the integration tests we rely on the hbm2ddl tool to generate the in-memory database structure. Tests of our database layer fail with Hibernate, when an @Entity contains one or more @ElementCollection annotations.

Environment

None

Assignee

Unassigned

Reporter

Dave Schoorl

Labels

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

Yes, likely

Pull Request

None

backportDecision

None

backportReEvaluate

None

Priority

Minor
Configure