通过JDBC语句执行DDL“ drop sequence player_seq”时出错

时间:2018-12-19 08:15:15

标签: hibernate sql-server-2008

在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

1 个答案:

答案 0 :(得分:1)

我使用以下代码更新了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() {
    }