2017-06-11 58 views
1

我认为这可能是这可能dupplicate:Schema-validation: missing table [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 & setters 

用户:

@Entity 
public class User { 
    @Id 
    @Column(name = "USER_ID") 
    @GeneratedValue(strategy = GenerationType.SEQUENCE) 
    private long userId; 

    private String username; 
    private String password; 

    @OneToMany(mappedBy="user",cascade=CascadeType.ALL) 
    private List<Game> games; 

    @ElementCollection 
    private List<Date> startSessions; 

    public User() {} 

    public User(String username, String password, List<Game> games, List<Date> startSessions) { 
     super(); 
     this.username = username; 
     this.password = password; 
     this.games = games; 
     this.startSessions = startSessions; 
    } 
} 

回答

0

validate验证该实体是针对目标相兼容,在一定程度上它是不是万无一失的。总之,无论你的数据库试图验证对不具有表叫在其中存储实体game

这个答案进入什么validate做更多的细节。

Hibernate - hibernate.hbm2ddl.auto = validate

具体而言,

checks the presence of tables, columns, id generators

不知道你的数据库/预期(你希望它来创建或使用迁飞/ Liquibase创建/更新数据库等),我可以”如果validate对于您的用例正确,请回答。

你可以尝试create-drop创建和删除的启动/关闭表,但是这不是在数据库中的任何生产控制的解决方案。

+0

我解决了问题,并创建表[游戏],现在它工作正常。 – Rares

+0

您可以检查这个问题PLZ? https://stackoverflow.com/q/44485076/7947794 – Rares