主键生成策略

  //程序控制生成主键之后直接连同主键添加数据进表

 @GenericGenerator(name = "generator", strategy = "assigned") @Id @GeneratedValue(generator = "generator") @Column(name = "id", unique = true, nullable = false, length = 32)

2.

  //zi自增长  integer类型id
    @Id
    @Column(name="id")
    @GeneratedValue(strategy=GenerationType.IDENTITY)        

 3.

//数据库自动生成主键  32位uuid
    @GenericGenerator(name = "generator", strategy = "uuid")
    @Id
    @GeneratedValue(generator = "generator")
    @Column(name = "id", unique = true, nullable = false, length = 32)

 

posted @ 2017-08-04 17:13  天涯已可  阅读(202)  评论(0编辑  收藏  举报