小编Rar*_*res的帖子

OneToMany 关系中的 StackoverflowError JPA

所以我有两个类:游戏和用户。用户可以玩 1 个或多个游戏,因此OneToMany它们之间是一种关系。这是课程。

我尝试使类之间的关系双向化。

游戏:

@Entity
public class Game {
    @Id
    @Column(name = "GAME_NUMBER")
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private long gameNumber;

    private int playerScore;
    private int NPCScore;
    private Date datetime;

    @ManyToOne
    @JoinColumn(name="USER_ID")
    private User user;

    public Game() {}

    public Game(int playerScore, int nPCScore, Date datetime) {
        super();
        this.playerScore = playerScore;
        this.NPCScore = nPCScore;
        this.datetime = datetime;
    }

    public User getUser() {
        return user;
    }
} + getters & setters for attributes
Run Code Online (Sandbox Code Playgroud)

用户:

@Entity
public class User {
    @Id
    @Column(name …
Run Code Online (Sandbox Code Playgroud)

jpa one-to-many spring-boot

5
推荐指数
1
解决办法
5416
查看次数

模式验证:缺少表格[游戏]

我认为这可能是重复的:模式验证:缺少表[hibernate_sequences],但我无法弄清楚。

因此,在我的application.properties文件中,我有此选项:spring.jpa.hibernate.ddl-auto=validate并且收到此错误:

Schema-validation: missing table [game]

为什么我收到这个?

这是我的Game课和User课:

游戏:

@Entity
public class Game {
    @Id
    @Column(name = "GAME_NUMBER")
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    private long gameNumber;

    private int playerScore;
    private int NPCScore;
    private Date datetime;

    @ManyToOne
    @JoinColumn(name="USER_ID")
    private User user;

    public Game() {}

    public Game(int playerScore, int nPCScore, Date datetime) {
        super();
        this.playerScore = playerScore;
        this.NPCScore = nPCScore;
        this.datetime = datetime;
    }

    public User getUser() {
        return user;
    }
} + getters …
Run Code Online (Sandbox Code Playgroud)

jpa spring-boot

2
推荐指数
4
解决办法
2万
查看次数

标签 统计

jpa ×2

spring-boot ×2

one-to-many ×1