Hi everybody,
we have a very simple case
Code:
public class Building...
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "ID_BUILDING", nullable = false)
List<Address> address = ...
public class Address...
and pretty much all the relations in our modell are like this one, that is fine, but...
In only one use case when we have to delete one huge root record Hibernate generates a big amount of DELETE.
We tryed to modify the mapping to use the @OnDelete(action=OnDeleteAction.CASCADE) this way
Code:
public class Building...
@OneToMany(mappedBy = "building", cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@OnDelete(action=OnDeleteAction.CASCADE)
List<Address> address = ...
public class Address...
@ManyToOne
@JoinColumn(name="ID_BUILDING", insertable=false, updatable=false)
Building building;
but now the owner of the relationship is Address and that changes the way Hibernate generates its requests.
We are very close to release the application in production and we cannot do so deep changes.
Is it a way to use the @OnDelete(action=OnDeleteAction.CASCADE) but not with an inverse relation (aka inverse=false) with JPA?
Thank you for your help.