Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/UserGuide/JPA/Advanced JPA Development/Schema Generation/CascadeOnDelete"
< EclipseLink | UserGuide | JPA | Advanced JPA Development | Schema Generation
m |
m |
||
Line 19: | Line 19: | ||
|+ ''CascadeOnDelete'' | |+ ''CascadeOnDelete'' | ||
|- | |- | ||
− | | '''On this...'' | + | | '''On this object...''' ||'''CascadeOnDelete does this...''' |
|- | |- | ||
| Entity|| Defines that secondary or joined inheritance tables should cascade the delete on the database | | Entity|| Defines that secondary or joined inheritance tables should cascade the delete on the database |
Revision as of 14:27, 31 January 2011
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API CascadeOnDelete
@CascadeOnDelete
--THIS PAGE IS IN PROGRESS --
ON DELETE CASCADE is a database foreign key constraint option that automatically removes the dependent rows.
Use the @CascadeOnDelete annotation or the cascadeOnDelete property to specify that a delete operation performed on a database object is cascaded on secondary or related tables.
On this object... | CascadeOnDelete does this... |
Entity | Defines that secondary or joined inheritance tables should cascade the delete on the database |
OneToOne mapping | The related object is deleted cascaded on the database. This is only allowed for mappedBy/target-foriegn key OneToOne mappings (because of constraint direction). |
OneToMany mapping | The related objects are deleted cascaded on the database. |
ManyToMany mapping | The join table is deleted cascaded on the database (target objects cannot be cascade even if private because of constraint direction). |
DirectCollection | The direct table is deleted cascaded on the database. |
AggregateCollection | The aggregate table is deleted cascaded on the database. |
@Target(value={METHOD,FIELD,TYPE}) @Retention(value=RUNTIME) public @interface CascadeOnDelete
Config files
In the orm.xml descriptor file, specify cascade on delete as follows:
<entity cascadeOnDelete="true"> <one-to-one cascadeOnDelete="true"> <one-to-many cascadeOnDelete="true"> <many-to-many cascadeOnDelete="true">