@OnDelete available also on @ManyToMany relationships
-----------------------------------------------------
Key: HHH-5875
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5875
Project: Hibernate Core
Issue Type: Improvement
Components: annotations
Affects Versions: 3.6.0
Reporter: Zdenek Hrib
When using @ManyToMany annotation and it creates a mapping table (eg. ACCOUNTS, PERSONS,
ACOUNTS_PERSONS) it is not possible to mark the field with
@OnDelete(action=OnDeleteAction.CASCADE).
Therefore both foreign key contraints on the mapping table are created as "ON UPDATE
NO ACTION ON DELETE NO ACTION". It would be great to use the
@OnDelete(action=OnDeleteAction.CASCADE) to change it to "ON UPDATE NO ACTION ON
DELETE CASCADE".
If I comment out the following lines line in org\hibernate\mapping\Collection.java then
one of the two FK contraints could be created as "ON UPDATE NO ACTION ON DELETE
CASCADE" by using @OnDelete(action=OnDeleteAction.CASCADE), but still I cannot change
it on the second FK constraint.
public void validate(Mapping mapping) throws MappingException {
// if ( getKey().isCascadeDeleteEnabled() && ( !isInverse() || !(isOneToMany()) )
) {
// throw new MappingException(
// "only inverse one-to-many associations may use on-delete=\"cascade\":
"
// + getRole() );
// }
I had attached the example source.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira