hibernate用注解(annotation)配置sequence

@Id
@SequenceGenerator(name="sequenceGenerator",sequenceName="ACTIVITIESSCOPE_SEQ")
@GeneratedValue(generator="sequenceGenerator",strategy=GenerationType.SEQUENCE)
@Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)
public Long getId() {
   return this.id;
}

注意:@GeneratedValue中的generator不是sequence的名字,而是@SequenceGenerator中的name的名字;@SequenceGenerator中的sequenceName才是定义sequence的名字。

 
 
上一篇:nodeJS之crypto模块md5和Hmac加密


下一篇:数据库中主键和外键