Im trying to create to domain objects with a OneToOne relationship. A is the parent and B is the child.
I tried many different ways to cascade deletions from A to B but when i look a the database creation, it doesnt set up ON DELETE CASCADE.
Can someone see what im doing wrong
A:
@Entity
@Table(name = "financeaccountcurrencymapping")
public class FinanceAccountCurrencyMapping implements Serializable {
@Id
@GeneratedValue
private long id;
@OneToOne(cascade = CascadeType.ALL, optional = false, orphanRemoval = true, mappedBy = "financeAccountCurrencyMapping")
private FinanceAccount financeAccount;
I know that either CascadeType.ALL or orphanRemoval should do the trick, but they dont.
B:
@Entity
@Table(name = "financeaccount")
public class FinanceAccount implements Serializable {
@OneToOne(optional = true)
private FinanceAccountCurrencyMapping financeAccountCurrencyMapping;
Can someone see why it doesnt cascade deletions?
I solved it, but not with JPA
i set @OnDelete(action = OnDeleteAction.CASCADE) on the child