开发者

is there delete orphen in JPA

开发者 https://www.devze.com 2023-02-10 00:30 出处:网络
I have group and user where group must have an owner otherwise he couldn\'t exist in hibernate in order to achieve this outcome I do :

I have group and user where group must have an owner otherwise he couldn't exist in hibernate in order to achieve this outcome I do :

@ManyToOne
@org.hibernate.ann开发者_C百科otations.CascadeType.DELETE_ORPHAN
private User owner;

(inside my group entity)

my question is how to do it when my all project configuration is JPA 2.0 ?


I have solve the problem , not the ideal way but it does the work :

(inside group)

@ManyToOne(cascade=CascadeType.ALL,optional=false)
private User owner;

even thought when deleting the user the group is not deleted but this is for the logic of the application to deduce...

0

精彩评论

暂无评论...
验证码 换一张
取 消