Hi Emmanuel, this is the script of the table that was created by hibernate...

CREATE TABLE  `intranetejb`.`unit` (
  |   `unitCode` bigint(20) NOT NULL auto_increment,
  |   `unitName` varchar(255) default NULL,
  |   `superUnitCode` bigint(20) default NULL,
  |   PRIMARY KEY  (`unitCode`),
  |   KEY `FK284DA4E626B09B` (`unitCode`),
  |   KEY `FK284DA41AB47516` (`superUnitCode`),
  |   CONSTRAINT `FK284DA41AB47516` FOREIGN KEY (`superUnitCode`) REFERENCES 
`unit` (`unitCode`),
  |   CONSTRAINT `FK284DA4E626B09B` FOREIGN KEY (`unitCode`) REFERENCES `unit` 
(`unitCode`)
  | ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

When I am trying to insert a record in the database (not in EJB)
INSERT INTO `unit` (`unitCode`, `unitName`, `superUnitCode`) VALUES
  | (1,'My unit',NULL)
I get this error...
Cannot add or update a child row: a foreign key constraint fails 
(`intranetejb/unit`, CONSTRAINT `FK284DA4E626B09B` FOREIGN KEY (`unitCode`) 
REFERENCES `unit` (`unitCode`))

When I delete the constraint, I'm able to insert the record.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3933910#3933910

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3933910


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to