Spring Boot 项目由于架构验证而无法运行:缺少序列 [hibernate_sequence]
当我尝试运行Spring Boot和Hibernate应用程序时,我发现它正在掉落,因为:
org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing sequence [hibernate_sequence]
但我不明白为什么这是因为我没有使用Hibernate序列。我的表,在Apache Derby中,如下:
CREATE TABLE TEAM (
TEAM_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
NAME VARCHAR(50) NOT NULL,
CONSTRAINT PK_TEAM PRIMARY KEY(Team_Id)
);
CREATE TABLE PLAYER (
PLAYER_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
NAME VARCHAR(50) NOT NULL,
NUM INTEGER NOT NULL,
POSITION VARCHAR(50) NOT NULL,
TEAM_ID INTEGER,
CONSTRAINT PK_PLAYER PRIMARY KEY(PLAYER_ID),
CONSTRAINT FK_PLAYER FOREIGN KEY(TEAM_ID) REFERENCES TEAM(TEAM_ID)
);
我的应用程序的文件是:application.properties
# Hibernate table generation.
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DerbyTenSevenDialect
spring.jpa.show-sql=true
# Apache Derby settings
spring.datasource.driverClassName=org.apache.derby.jdbc.ClientDriver
spring.datasource.url=jdbc:derby://localhost:1527/Library
spring.datasource.username=username
spring.datasource.password=password`
涉及的两个Java类是:
@Entity
@Table(name = "TEAM")
public class Team {
@Id
@Column(name = "TEAM_ID", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer teamId;
@Column(name = "NAME")
private String name;
@OneToMany(cascade = CascadeType.ALL,
fetch = FetchType.EAGER,
mappedBy = "team")
private List<Player> players;
和:
@Entity
@Table(name = "PLAYER")
public class Player {
@Id
@Column(name = "PLAYER_ID", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer playerId;
@Column(name = "NAME")
private String name;
@Column(name = "NUM")
private int num;
@Column(name = "POSITION")
private String position;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "TEAM_ID", nullable = true)
private Team team;
任何人都可以建议我错在哪里吗?
Maven 依赖关系包括:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.14.2.0</version>
</dependency>
</dependencies>