spring.jpa.hibernate.ddl-auto=update mariadb can not auto create Database indexes or Foreign key or column

875 views Asked by At

1.spring boot

spring-boot-gradle-plugin:1.4.2.RELEASE

2.gradle

 dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '1.1.8'
}

3.application.properties

spring.jpa.hibernate.ddl-auto=update

4.Entity

    @Entity public class Users { @Id
    private int id;

    @Column(nullable = false,unique = true)
    private int userId;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }
}

Hibernate can not auto create Database indexes or Foreign key or constraint or add column

but,when

spring-boot-gradle-plugin:1.2.4.RELEASE

everything is normal

How to solve

1

There are 1 answers

0
Andy On BEST ANSWER

Found the problem, mariadb version is too low

compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '1.1.8'

change to

compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '1.5.6'

everything is OK !