Hibernate version: 3.2
Hibernate-Annotations: 3.3.0GA
PostgreSQL: 8.2.4
I have seen a number of posts on PostgreSQL and IDs, but nothing quite like what I experienced.
In an empty "Users" table, I added three users: one with ID=1, one with ID=2 and one with ID=63.
From then on, I delegated the rest of the job to my application, through Hibernate. I was expecting the following users to be numbered 64, 65, 66, etc. But the users seem to be numbered 200, 700, 1200, 1700, etc.
Has anyone ever seen anything like it?
Here is the User object with its Annotations:
Code:
@Entity @Table(name="users", schema="users")
@SequenceGenerator(name="USER_SEQ", sequenceName="users.users_id_seq")
public class User extends AbstractPersistentObject {
private Long id;
private String username;
// etc.
public User() { /* do nothing */ }
@Id @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="USER_SEQ")
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
// etc.
}
And here is the definition of the PostgreSQL sequence, according to pgAdmin:
Code:
CREATE SEQUENCE users.users_id_seq
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 46
CACHE 1;