Im trying to create to domain objects with a OneToOne relationship. A is the parent and B is the child.
我试图创建具有OneToOne关系的域对象。 A是父母,B是孩子。
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.
我尝试了许多不同的方法来级联从A到B的删除,但是当我查看数据库创建时,它没有设置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.
我知道CascadeType.ALL或orphanRemoval应该做的伎俩,但他们不这样做。
B:
@Entity
@Table(name = "financeaccount")
public class FinanceAccount implements Serializable {
@OneToOne(optional = true)
private FinanceAccountCurrencyMapping financeAccountCurrencyMapping;
Can someone see why it doesnt cascade deletions?
有人能看出它为什么没有级联删除?
1 个解决方案
#1
0
I solved it, but not with JPA
我解决了它,但不是JPA
i set @OnDelete(action = OnDeleteAction.CASCADE) on the child
我在孩子身上设置了@OnDelete(action = OnDeleteAction.CASCADE)
#1
0
I solved it, but not with JPA
我解决了它,但不是JPA
i set @OnDelete(action = OnDeleteAction.CASCADE) on the child
我在孩子身上设置了@OnDelete(action = OnDeleteAction.CASCADE)