I'm noticing something interesting with hibernate_sequence in my PostgreSQL database. Up until now, the sequence (which is used by all tables in my database) has been incrementing by 1. That's not the case anymore, however.
Currently, hibernate_sequence shows a value of 43270. If I SELECT nextval('hibernate_sequence');
it will correctly report 43271
.
When I insert data into my table, however, the sequence ID is now 1872053
!
For the life of me, I cannot figure out why but it is affecting some database scripts that I have running to transfer data on a nightly basis between different environments.
I'm hoping it does not have anything to do with the following article which states that declaring @GeneratedValue(strategy=GenerationType.SEQUENCE)
"uses HiLo strategy which allocates IDs in blocks of 50 by default."
Hibernate use of PostgreSQL sequence does not affect sequence table
If that were the case, would there be such a big jump in sequence ID's? From 43271
to 1872053
?
It's almost as if there is a "disconnect" with the hibernate_sequence. When I INSERT a second event, the ID is 1872053 but the hibernate_sequence value is no longer changing (it will still stay at 43421).
Are there any other possible explanations?
Thanks!
Code example:
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE)
private Integer id;