|
17 | 17 | import org.hibernate.AssertionFailure; |
18 | 18 | import org.hibernate.FetchMode; |
19 | 19 | import org.hibernate.annotations.CascadeType; |
| 20 | +import org.hibernate.annotations.OnDeleteAction; |
20 | 21 | import org.hibernate.annotations.SourceType; |
21 | 22 | import org.hibernate.boot.MappingException; |
22 | 23 | import org.hibernate.boot.jaxb.Origin; |
@@ -562,7 +563,7 @@ private void bindJoinedSubclassEntity( |
562 | 563 | keyBinding.makeNationalized(); |
563 | 564 | } |
564 | 565 | entityDescriptor.setKey( keyBinding ); |
565 | | - keyBinding.setCascadeDeleteEnabled( entitySource.isCascadeDeleteEnabled() ); |
| 566 | + keyBinding.setOnDeleteAction( getOnDeleteAction( entitySource.isCascadeDeleteEnabled() ) ); |
566 | 567 | relationalObjectBinder.bindColumns( |
567 | 568 | mappingDocument, |
568 | 569 | entitySource.getPrimaryKeyColumnSources(), |
@@ -593,7 +594,6 @@ public Identifier determineImplicitName(LocalMetadataBuildingContext context) { |
593 | 594 |
|
594 | 595 | bindJoinedSubclassEntities( entitySource, entityDescriptor ); |
595 | 596 | } |
596 | | - |
597 | 597 | private void bindUnionSubclassEntities( |
598 | 598 | EntitySource entitySource, |
599 | 599 | PersistentClass superEntityDescriptor) { |
@@ -1622,7 +1622,7 @@ private void bindSecondaryTable( |
1622 | 1622 | } |
1623 | 1623 | secondaryTableJoin.setKey( keyBinding ); |
1624 | 1624 |
|
1625 | | - keyBinding.setCascadeDeleteEnabled( secondaryTableSource.isCascadeDeleteEnabled() ); |
| 1625 | + keyBinding.setOnDeleteAction( getOnDeleteAction( secondaryTableSource.isCascadeDeleteEnabled() ) ); |
1626 | 1626 |
|
1627 | 1627 | // NOTE : no Type info to bind... |
1628 | 1628 |
|
@@ -1972,7 +1972,7 @@ public void bindOneToOne( |
1972 | 1972 | setForeignKeyName( oneToOneBinding, oneToOneSource.getExplicitForeignKeyName() ); |
1973 | 1973 | } |
1974 | 1974 |
|
1975 | | - oneToOneBinding.setCascadeDeleteEnabled( oneToOneSource.isCascadeDeleteEnabled() ); |
| 1975 | + oneToOneBinding.setOnDeleteAction( getOnDeleteAction( oneToOneSource.isCascadeDeleteEnabled() ) ); |
1976 | 1976 | } |
1977 | 1977 |
|
1978 | 1978 | private Property createManyToOneAttribute( |
@@ -2121,7 +2121,7 @@ private void bindManyToOneAttribute( |
2121 | 2121 | } |
2122 | 2122 | } |
2123 | 2123 |
|
2124 | | - manyToOneBinding.setCascadeDeleteEnabled( manyToOneSource.isCascadeDeleteEnabled() ); |
| 2124 | + manyToOneBinding.setOnDeleteAction( getOnDeleteAction( manyToOneSource.isCascadeDeleteEnabled() ) ); |
2125 | 2125 | } |
2126 | 2126 |
|
2127 | 2127 | private static void setForeignKeyName(SimpleValue manyToOneBinding, String foreignKeyName) { |
@@ -3203,8 +3203,8 @@ protected void bindCollectionKey() { |
3203 | 3203 | keyVal |
3204 | 3204 | ); |
3205 | 3205 | setForeignKeyName( key, keySource.getExplicitForeignKeyName() ); |
3206 | | - key.setCascadeDeleteEnabled( getPluralAttributeSource().getKeySource().isCascadeDeleteEnabled() ); |
3207 | | -// |
| 3206 | + key.setOnDeleteAction( getOnDeleteAction( getPluralAttributeSource().getKeySource().isCascadeDeleteEnabled() ) ); |
| 3207 | + |
3208 | 3208 | // final ImplicitJoinColumnNameSource.Nature implicitNamingNature; |
3209 | 3209 | // if ( getPluralAttributeSource().getElementSource() instanceof PluralAttributeElementSourceManyToMany |
3210 | 3210 | // || getPluralAttributeSource().getElementSource() instanceof PluralAttributeElementSourceOneToMany ) { |
@@ -4069,4 +4069,8 @@ private String columns(Value value) { |
4069 | 4069 | } |
4070 | 4070 | return builder.toString(); |
4071 | 4071 | } |
| 4072 | + |
| 4073 | + private static OnDeleteAction getOnDeleteAction(boolean entitySource) { |
| 4074 | + return entitySource ? OnDeleteAction.CASCADE : OnDeleteAction.NO_ACTION; |
| 4075 | + } |
4072 | 4076 | } |
0 commit comments