You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: HibernateSpringBootBatchDeleteCascadeDelete/README.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -1,20 +1,20 @@
1
-
**[How To Batch Deletes In MySQL Via SQL "on delete cascade"](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootBatchDeleteCascadeDelete)**
1
+
**[How To Batch Deletes In MySQL Via SQL "ON DELETE CASCADE"](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootBatchDeleteCascadeDelete)**
2
2
3
-
**Description:** Batch deletes in MySQL via `on delete cascade`. Auto-generated database schema will contain `ON DELETE CASCADE` directive.
3
+
**Description:** Batch deletes in MySQL via `ON DELETE CASCADE`. Auto-generated database schema will contain `ON DELETE CASCADE` directive.
4
4
5
-
**Note:** Spring `deleteAllInBatch()` and `deleteInBatch()` don't use batching. The first one simply triggers a `delete from entity_name` statement, while the second one triggers a `delete from entity_name where id=? or id=? or id=? ...` statement. Rely on `delete()`method.
5
+
**Note:** Spring `deleteAllInBatch()` and `deleteInBatch()` don't use *classical* delete batching. The first one simply triggers a `delete from entity_name` statement, while the second one triggers a `delete from entity_name where id=? or id=? or id=? ...` statement. Both of them take advantage on `ON DELETE CASCADE`. For *classical*delete batching rely on `deleteAll()`, `deleteAll(Iterable<? extends T> entities)` or `delete()`method. Behind the scene, the two flavors of `deleteAll()` relies on `delete()`.
6
6
7
7
**Key points:**\
8
-
- in this example, we have a `Tournament` entity and each tournament can have several `TennisPlayer` (*one-to-many*)\
8
+
- in this application, we have a `Author` entity and each author can have several `Book` (*one-to-many*)\
9
9
- first, we remove `orphanRemoval` or set it to `false`\
10
10
- second, we use only `CascadeType.PERSIST` and `CascadeType.MERGE`\
11
11
- third, we set `@OnDelete(action = OnDeleteAction.CASCADE)` next to `@OneToMany`\
12
12
- fourth, we set `spring.jpa.properties.hibernate.dialect` to `org.hibernate.dialect.MySQL5InnoDBDialect`\
13
-
- fifth, we use the Spring `delete()` method to delete all `Tournament`
78.**[How To Batch Deletes In MySQL Via SQL "on delete cascade"](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootBatchDeleteCascadeDelete)**
1089
+
78.**[How To Batch Deletes In MySQL Via SQL "ON DELETE CASCADE"](https://github.com/AnghelLeonard/Hibernate-SpringBoot/tree/master/HibernateSpringBootBatchDeleteCascadeDelete)**
1090
1090
1091
-
**Description:** Batch deletes in MySQL via `on delete cascade`. Auto-generated database schema will contain `ON DELETE CASCADE` directive.
1091
+
**Description:** Batch deletes in MySQL via `ON DELETE CASCADE`. Auto-generated database schema will contain `ON DELETE CASCADE` directive.
1092
1092
1093
-
**Note:** Spring `deleteAllInBatch()` and `deleteInBatch()` don't use batching. The first one simply triggers a `delete from entity_name` statement, while the second one triggers a `delete from entity_name where id=? or id=? or id=? ...` statement. Rely on `delete()`method.
1093
+
**Note:** Spring `deleteAllInBatch()` and `deleteInBatch()` don't use *classical* delete batching. The first one simply triggers a `delete from entity_name` statement, while the second one triggers a `delete from entity_name where id=? or id=? or id=? ...` statement. Both of them take advantage on `ON DELETE CASCADE`. For *classical*delete batching rely on `deleteAll()`, `deleteAll(Iterable<? extends T> entities)` or `delete()`method. Behind the scene, the two flavors of `deleteAll()` relies on `delete()`.
1094
1094
1095
1095
**Key points:**\
1096
-
- in this example, we have a `Tournament` entity and each tournament can have several `TennisPlayer` (*one-to-many*)\
1096
+
- in this application, we have a `Author` entity and each author can have several `Book` (*one-to-many*)\
1097
1097
- first, we remove `orphanRemoval` or set it to `false`\
1098
1098
- second, we use only `CascadeType.PERSIST` and `CascadeType.MERGE`\
1099
1099
- third, we set `@OnDelete(action = OnDeleteAction.CASCADE)` next to `@OneToMany`\
1100
1100
- fourth, we set `spring.jpa.properties.hibernate.dialect` to `org.hibernate.dialect.MySQL5InnoDBDialect`\
1101
-
- fifth, we use the Spring `delete()` method to delete all `Tournament`
0 commit comments