hibernate id自动生成

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")

你可能感兴趣的:(oracle,Hibernate,cache,user,开发工具,generator)