我正在努力建立一对一的关系,一场比赛有很多赛事。 当spring尝试创建此Match实体时,我收到以下错误:
引起:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 您的SQL语法有错误;检查手册 对应于您的MySQL服务器版本,以便使用正确的语法 'match(id bigint not null auto_increment,date varchar(255))附近, loser varchar(255),'第1行
这是我的Match.java
@Entity
@Table(uniqueConstraints = @UniqueConstraint(columnNames = "id"))
public class Match {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String victor;
private String loser;
private String date;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinTable(
name = "matches_events",
joinColumns = @JoinColumn(
name = "match_id", referencedColumnName = "id"),
inverseJoinColumns = @JoinColumn(
name = "event_id", referencedColumnName = "id"))
private Collection<Event> events;
public Match(String victor, String loser, String date) {
super();
this.victor = victor;
this.loser = loser;
this.date = date;
}
public Match() {
super();
}
public Match(String victor, String loser, String date, Collection<Event> events) {
super();
this.victor = victor;
this.loser = loser;
this.date = date;
this.events = events;
}
//Getters and setters...