通过JDBC语句执行DDL“drop sequence player_seq”时出错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过JDBC语句执行DDL“drop sequence player_seq”时出错相关的知识,希望对你有一定的参考价值。
在我的Entity类中,我编写了这段代码。
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "player_Sequence")
@SequenceGenerator(name = "player_Sequence", sequenceName = "PLAYER_SEQ")
但显示以下错误。
2018-12-19 13:49:54 WARN o.h.t.s.i.ExceptionHandlerLoggedImpl - GenerationTarget encountered exception accepting command : Error executing DDL "drop sequence team_seq" via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "drop sequence team_seq" via JDBC Statement
答案
我用以下代码更新了application.properties文件。
spring.jpa.hibernate.ddl-auto = update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.SQLServer2008Dialect
我必须在Entity类中使用@GeneratedValue
而不是Sequence。
@Entity
public class Player {
@GeneratedValue
@Id
private Long id;
@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 = false)
private Team team;
public Player() {
}
以上是关于通过JDBC语句执行DDL“drop sequence player_seq”时出错的主要内容,如果未能解决你的问题,请参考以下文章
通过JDBC语句执行DDL“drop sequence player_seq”时出错
org.hibernate.tool.schema.spi.CommandAcceptanceException:通过JDBC语句执行DDL时出错
在 Spring Boot 2、Hibernate、PostgreSQL 中通过 JDBC 语句执行 DDL 时出错