我认为这可能是重复的:模式验证:缺少表hibernate_sequences],但我无法弄清楚。
因此,在我的application.properties文件中,我有此选项:spring.jpa.hibernate.ddl-auto=validate并且收到此错误:
application.properties
spring.jpa.hibernate.ddl-auto=validate
Schema-validation: missing table [game]
为什么我收到这个?
这是我的Game课和User课:
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; } }
validate在某种程度上证明实体与目标兼容,这并非万无一失。无论如何,无论您要针对game哪个数据库进行验证,都没有一个用于存储实体的表。
validate
game
该答案将更详细地说明validate功能。
特别,
检查表,列,id生成器的存在
不知道您的数据库/期望(您希望创建它,还是使用Flyway / Liquibase创建/更新数据库等),如果validate您的用例正确,我将无法回答。
您可以尝试create-drop在启动/关闭时创建和删除表,但这不是对数据库进行任何生产控制的解决方案。
create-drop