Strange sequences counter in oracle
Hello!I got an question from a tester why two sequences in oracle have skipped 20 steps.
We have only seen this in a clustred environment with two JBoss and one databas.
In my own envionment with one JBoss and one database I have not been able to reproduce this.
When I look in the database (after a couple inserts) for two tables I see:
Table_A
ID 1
ID 21
ID 41
ID 42
ID 43
Table_B (refers to table A, many to one i think its called)
ID 1 FK_TABLE_B_ID 1
ID 21 FK_TABLE_B_ID 21
ID 41 FK_TABLE_B_ID 41
ID 42 FK_TABLE_B_ID 42
ID 43 FK_TABLE_B_ID 42
ID 44 FK_TABLE_B_ID 42
The 3 first inserts got steps by 20, but as soon I inserted more as you see in table B (all this from the JEE-application) it started to increment in a more nice way.
I first examined the ORM-object that uses Hibernate.
I found out that the two classes that maps these two tables seems to refer to different sequence, BUT WITH SAME NAME "seq":
public class TableA {
@SequenceGenerator(name = "seq", sequenceName = "TABLE_A_SEQ")
@GeneratedValue(generator = "seq")
@Id
@Column(name = "ID")
private String id;
public class TableB {
@SequenceGenerator(name = "seq", sequenceName = "TABLE_B_SEQ")
@GeneratedValue(generator = "seq")
@Id
@Column(name = "ID")
private String id;
Could this be the error??
How ever when I look at sequences in oracle I see that there is a cache with 20, and that there says no order, perhaps this could be the reason??
And that this is a expected behavior, that oracle can deliver one of the ones in the cache??
CREATE SEQUENCE TABLE_A_SEQ
START WITH 61
MAXVALUE 999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER;
CREATE SEQUENCE TABLE_B_SEQ
START WITH 61
MAXVALUE 999999999999999999999999999
MINVALUE 1
NOCYCLE
CACHE 20
NOORDER;
What do you think guys?
Best regards/Mange takk!
Fredrik from Sweden.
Feel free to reply in danish!