创建实体时执行DDL错误

时间:2019-04-08 15:43:43

标签: java spring hibernate

我有一个简单的实体,没有任何关系,但是当我运行我的应用程序时,它抛出了这个问题:

         Error executing DDL "create table tasks (id bigint not null, car bigint, created_at datetime(6), status varchar(255), to bigint, updated_at datetime(6), primary key (id)) engine=InnoDB" via JDBC Statement

我的实体非常简单。这是它的代码:

 @Entity
  public class Task {
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private long id;


  @Column(name = "car")
  private Long car;


  @Column(name = "to")
   private Long to;


  @Enumerated(EnumType.STRING)
    private Task.Status status;
    public enum Status {
     NEW,
     DONE,
     }

 @CreationTimestamp
 private Date createdAt;

 @UpdateTimestamp
 private Date updatedAt;
 }

1 个答案:

答案 0 :(得分:1)

“ to”是SQL中的保留字。 尝试给您的字段“改成”不同的名称,例如

Timer1 = new System.Windows.Forms.Timer() { Interval = 50, Enabled = false };