如何删除表如果存在jpa h2 spring启动



我试图将用户实体添加到评论者实体中,但是我得到以下错误

SchemaDropperImpl$DelayedDropActionImpl : HHH000478: Unsuccessful: drop table if exists user cascade 

这是我的实体


@Entity
public class Review extends BaseEntity {

public Review(int rating, String description) {
this.setRating(rating);
this.setDescription(description);
}
public Course getCourse() {
return course;
}
public void setCourse(Course course) {
this.course = course;
}
@ManyToOne
private Course course;
public User getReviewer() {
return reviewer;
}
public void setReviewer(User reviewer) {
this.reviewer = reviewer;
}
@ManyToOne(cascade = CascadeType.ALL)
private User reviewer;

public Review() {
super();
}
}

我已经尝试添加cascade = CascadeType。

您可以在application.properties.

中使用下面的属性
spring.jpa.hibernate.ddl-auto = create

如果表不存在,该属性将创建一个新表。

最新更新