[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-6324) Hibernate one-to-many relationship together with Oracle integrity referential
Gail Badner (JIRA)
noreply at atlassian.com
Mon Aug 15 18:12:05 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-6324?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gail Badner resolved HHH-6324.
------------------------------
Resolution: Rejected
Assignee: Gail Badner
Delete-orphan is designed to work as you describe.
Please use the user forum for help (https://forum.hibernate.org/).
> Hibernate one-to-many relationship together with Oracle integrity referential
> -----------------------------------------------------------------------------
>
> Key: HHH-6324
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6324
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.6.0
> Environment: JBoss 6.0 standard community edition. Eclipese Helios. Hibernate 3.6.0.
> Reporter: lorenzo pergolini
> Assignee: Gail Badner
> Attachments: model.PNG
>
>
> We defined a one to many relationship between two tables: Role and RoleAccount.
> We managed the integrity referential directly on Oracle.
> Our need is to delete one or more RoleAccount related to a Role, but we also need to keep an Oracle integrity referential when we try to delete a Role that has at least a RoleAccount linked.
> So what we expect from Hibernate is that there would exist a cascade option, besides delete and delete-orphan, that when trying to delete a Role that has at least a RoleAccount, it doesn't delete first the orphans and then the parents, but the opposite so to raise an integrity referential exception.
> Instead if we use delete-orphan option, Hibernate first deletes all the orphan children(RoleAccounts) and then delete the parent(Role), without raising any Oracle integrity referential exception.
> We know that this can be done by removing the delete option from cascade (cascade="save-update"), but then we manually have to delete RoleAccounts.
> Below I attached part of the mappings and integrity referential sql script:
> <!----------------Role -------------->
> <bag name="roleFunctions" table="`AdmRoleFunction`" inverse="true" fetch="select" cascade="save-update">
> <key>
> <column name="`admRoleId`" not-null="true" />
> </key>
> <one-to-many class="it.apra.logistic.model.admin.RoleFunction" />
> </bag>
> <!----------------RoleAccounts -------------->
> <bag name="roleAccounts" table="`AdmRoleAccount`" inverse="false" fetch="select" cascade="save-update,delete">
> <key>
> <column name="`admRoleId`" not-null="true" />
> </key>
> <one-to-many class="it.apra.logistic.model.admin.RoleAccount" />
> </bag>
>
> <!------Integrity referential Sql-------------->
> ALTER TABLE "AdmRoleAccount" ADD CONSTRAINT "FkAdmRole2" FOREIGN KEY ("admRoleId") REFERENCES "AdmRole" ("id") /
> ALTER TABLE "AdmRoleAccount" ADD CONSTRAINT "FkAdmAccount2" FOREIGN KEY ("admAccountId") REFERENCES "AdmAccount" ("id") ON DELETE CASCADE /
>
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list