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

相关内容