休眠约束错误
在我的项目中,我使用 hibernate 和 oracle 作为数据库。
我有两个具有外键关系的表。
在休眠状态下,我有一对多的关系。
我的一对多代码
集 name="classname"cascade="all,all-delete-orphan
一对多 ..... on-delete="cascade"
set
但每当我删除时,我都会违反约束错误... ora:222错误无法删除它有子表 我有级联=“全部”,但仍然出现错误...
插入时也出现同样的错误。我将主键作为 ID 属性,它是序列。 所以在外键ID属性中它不插入并且获取null无法插入错误.. 有人经历过这些错误吗?
In my project i m using using hibernate and oracle as DB.
I am having two tables with foreign key relationship.
In hibernate I m have one-to-many relationship.
my one-to-many code
set name="classname" cascade="all,all-delete-orphan
one-to-many ..... on-delete="cascade"
set
But whenever i detele i am getting constraint violation error...
ora:222 error cannot delete it has child table
I have cascade="all" but y still the error comes...
Same error while inserting too. I am having primarykey as ID attribute which is sequence.
So in foreignkey ID attribute its not inserting and getting null cannot be inserted error ..
Have any one experienced these errors ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
或:
而不是: 另外
请确保将关联的一侧标记为:。
,如果关联是双向的,
如果这不能解决您的问题,请尝试稍微清理一下您的解释并提供更多信息(例如所涉及的两个对象的完整映射文件和 Java 类)。
Try:
or:
instead of:
Also, make sure you mark one side of the association with:
if the association is bi-directional.
If that doesn't solve your issue, please try to clean up your explanation a little and provide more information (like the full mapping files and Java classes for the two objects involved).