【发布时间】:2019-10-29 23:25:02
【问题描述】:
我正在尝试将 Spring Boot 应用程序部署到 Heroku。它使用RemoteMysl 提供的远程数据库。但是,在构建应用程序时,它会在数据库中创建除一张表之外的所有表。我在 Heroku 应用程序日志中收到以下错误。
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL 语法;检查与您的 MySQL 服务器相对应的手册 删除时在 'groups (id) 附近使用的正确语法的版本 级联'在第 1 行
组模型
package com.itsfive.back.model;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.springframework.web.multipart.MultipartFile;
import com.itsfive.back.model.audit.DateAudit;
@Entity
@Table(name = "groups")
public class Group extends DateAudit{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@NotBlank
@Size(max = 30)
private String name;
@Size(max = 160)
private String description;
@OneToOne
@JoinColumn(name = "created_by_id", nullable = false)
private User created_by;
private String coverPhoto;
public User getCreated_by() {
return created_by;
}
public void setCreated_by(User created_by) {
this.created_by = created_by;
}
public String getCoverPhoto() {
return coverPhoto;
}
public void setCoverPhoto(String coverPhoto) {
this.coverPhoto = coverPhoto;
}
public Group(@NotBlank @Size(max = 30) String name, @Size(max = 160) String description,User created_by) {
super();
this.name = name;
this.description = description;
this.created_by = created_by;
}
public Group() {
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String groupName) {
this.name = groupName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public User getCreatedBy() {
return created_by;
}
public void setCreatedBy(User user) {
this.created_by = user;
}
}
【问题讨论】:
标签: hibernate spring-boot heroku