Hibernate OnDelete Cascade not working for MySql but Works on postgres and Ms-Sql

[亡魂溺海] 提交于 2019-12-03 00:40:55

This is what I did to resolve this problem based on Spring Boot.

Solution

from

// application.properties  
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect

to

spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

Explanation
As you can see below, it seems like the default value for CascadeDelete at MySQL5InnoDBDialect.java only support Cascade.

// MySQLDialect.java
@Override
    public boolean supportsCascadeDelete() {
        return false;
    }

// MySQL5InnoDBDialect.java
@Override
    public boolean supportsCascadeDelete() {
        return true;
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!