JPA2中的OnDelete是否有等效的批注 [英] Is there an equivalent annotation for OnDelete in JPA2

查看:130
本文介绍了JPA2中的OnDelete是否有等效的批注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import org.hibernate.annotations.OnDelete;

@OnDelete(action = org.hibernate.annotations.OnDeleteAction.CASCADE)
List<Foo> foos;

Hibernate注释OnDelete是否有等效的JPA2注释?

Is there an equivalent JPA2 annotation for the Hibernate annotation OnDelete?

推荐答案

尝试@OneToMany(cascade=CascadeType.Delete).因此,级联将由orm(休眠)而不是数据库处理.如果要在数据库中生成一个层叠,则唯一的休眠特定注释是唯一的方法.

Try @OneToMany(cascade=CascadeType.Delete). Thus the cascade will be handled by the orm (hibernate), and not the database. If you want to have a cascade generated in the DB, the hibernate-specific annotation is the only way.

这篇关于JPA2中的OnDelete是否有等效的批注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆