hibernate id自动生成

来源:互联网 发布:买道亨软件怎么买 编辑:程序博客网 时间:2024/05/08 12:05

oracle 使用sequences做为id,首先在oracle建一个sequence(用pl/sql开发工具创建,或者用代码

    create sequence USER_SEQUENCES
    minvalue 1
    maxvalue 2000
    start with 61
    increment by 1
    cache 20;实现).

在主键属性上加

  @SequenceGenerator(name = "USER_SEQUENCES_ID", sequenceName = "USER_SEQUENCES")
 @Id
 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "USER_SEQUENCES_ID")