Hibernate cascade and mysql foreign key

CREATE TABLE student (
    id          INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    teacher      INTEGER UNSIGNED NOT NULL,
    name         varchar(12) BINARY NOT NULL,
    sex    TINYINT NOT NULL DEFAULT 0,
    FOREIGN KEY fk_teacher (teacher) REFERENCES teacher(id)
        ON UPDATE CASCADE
        ON DELETE CASCADE

) engine=INNODB;

 

If we set  "ON UPDATE/DELETE CASCADE" on a foreign key, it is the same effect with configure hibernate CASCADE.

But if we set Hibernate cascade and foreign key cascade at the same time, then our project will use hibernate cascade first.

posted @ 2009-12-16 13:53  留心_frankliujava  阅读(627)  评论(0编辑  收藏  举报