springjpa停止关系创建新表

b4wnujal  于 2021-07-13  发布在  Java
关注(0)|答案(0)|浏览(306)

我正在尝试创建一些关系,当我创建了新表时,如何才能阻止这种情况的发生。这是我的家长课。

@Entity
public class Seasons {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int Season_Id;
private String season;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "season")
private List<Fixture> fixtures;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "season")
private List<Referee> referee;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "season")
private List<Team> team;
}

这是我试图在三个类之间建立关系的一个例子。这个是fixture类。

@Entity
public class Fixture {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int fixture_Id;
@OneToOne
private FixtureStats stats;
@OneToOne
private Referee referee;
@OneToOne
private Team  Home;
@OneToOne
private Team Away;
private int week;
@ManyToOne
private Seasons season;
}

当我运行程序时,这些是创建的表:
季节
裁判
季节.固定装置
季节.团队
我不想有一个私人的节日;但如果需要的话,我不得不接受。我试过搜索这个,但是找不到关于这个主题的任何东西。
更新:我现在使用了@joincolumn,但是出于某种原因,它只为fixture提供了一个列?这是最新的代码

@Entity
public class Seasons {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int Season_Id;
private String season;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn
private List<Fixture> fixtures;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn
private List<Referee> referee;
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn
private List<Team> team;

干杯

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题