In Oracle:
Create a sequence
create sequence seq_newsId increment by 1 start with 1 maxvalue 999999999;
SQL statement to get the sequence
select seq_newsid.nextval from sys.dual;
SQL to delete a sequence
DROP SEQUENCE seq_newsId;
In this way, the sequence in Oracle is created.
In Jpa:
Entity class configuration
1 @Id 2 3 @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="mseq") 4 5 @SequenceGenerator(name="mseq",sequenceName="seq_newsId",allocationSize=1) 6 7 @Column(name = "ENTID", unique = true, nullable = false, precision = 22, scale = 0) 8 9 public long getEntid() { 10 11 return this.entid; 12 13 }
sequenceName is the sequence created by itself in oracle. allocationSize must be specified as 1, otherwise it will grow by the default 50 numbers.