[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3334) Cascading breaks if parent table doesn't have Auto-inc

Gail Badner (JIRA) noreply at atlassian.com
Wed May 13 19:37:13 EDT 2009


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3334?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=33159#action_33159 ] 

Gail Badner commented on HHH-3334:
----------------------------------

I've checked the fix for HHH-3810 into Branch_3_2. I'll check it into the other branches tonight or tomorrow morning.

This should fix this issue as well.

I also checked in the test case attached to this issue and added another test case based it. These test cases are in org.hibernate.test.cascade.circle:
  org.hibernate.test.cascade.circle.MultiPathCircleCascadeTest
  org.hibernate.test.cascade.circle.CascadeMergeToChildBeforeParentTest

Another test case for merge-cascade is at:
  org.hibernate.test.cascade.MultiPathCascadeTest

Wallace, I have not tried your test case. Please let me know if the fix for HHH-3810 fixes your issue. If it doesn't, I'll take a look at it.

You can check the code out from http://anonsvn.jboss.org/repos/hibernate/core/branches/Branch_3_2/.

If you do try it out, please let me know if it works for your issue.

Thanks,
Gail

> Cascading breaks if parent table doesn't have Auto-inc
> ------------------------------------------------------
>
>                 Key: HHH-3334
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3334
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.4.sp1, 3.2.5, 3.2.6, 3.3.0.CR1
>         Environment: tested on MySql, and hibernate versions (with annotations) v3.2.4 to 3.3.0CR1
>            Reporter: Wallace Wadge
>         Attachments: AbstractSaveEventListener.java, brokenCascade.zip
>
>
> (reposting here from forum)
> Consider:
> - a table with an assigned PK (i.e. not auto-increment), let's call this "A"
> - Another table ("B") linked to the table listed above but with it's PK set to auto-increment.
> Now if you try to save B with cascading switched on, it will break. From the little debugging I've done it looks like:
> a) hibernate detects that A needs to be saved first, but puts it into some sort of queue.
> b) when it hits B, it short-circuits this save queue and tries to save B immediately so as to obtain a PK reference for B. This fails since A hasn't been yet been saved so it's link is still null.
> Schema used is listed below (MySQL):
> ----
> CREATE DATABASE `jira` /*!40100 DEFAULT CHARACTER SET latin1 */;
> DROP TABLE IF EXISTS `jira`.`parent`;
> CREATE TABLE `jira`.`parent` (
> `parent_id` int(10) unsigned NOT NULL,
> PRIMARY KEY (`parent_id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
> DROP TABLE IF EXISTS `jira`.`child`;
> CREATE TABLE `jira`.`child` (
> `child_id` int(10) unsigned NOT NULL auto_increment,
> `parent_id` int(10) unsigned NOT NULL,
> PRIMARY KEY (`child_id`),
> KEY `FK_child_1` (`parent_id`),
> CONSTRAINT `FK_child_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`parent_id`)
> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list