From: Vladimir G. <vla...@du...> - 2010-01-27 18:46:25
|
Here is what happened to user_id and person_id in an empty database after I created a handful new users, starting with hibernate_sequence = 1000 (that's ONE thousand) user_id username person_id hibernate_sequence 10000 "vgapeyev"; 10010 1001 10001 "vgapeyev2"; 10011 1001 10002 "vgapeyev3"; 10012 1001 10020 "vgapeyev4"; 10030 1003 That is, Hibernate uses values from hibernate_sequence to generate PK ids in some cleverly mysterious ways. Consequently, the current declarations of PK columns like user_id bigint NOT NULL DEFAULT nextval('hibernate_sequence'::regclass); may deceive someone that an INSERT of a row without an ID explicitly specified would be ok, since the DB appears to know how to do the right thing. So, I'd propose to drop the default declarations, to avoid the deception: user_id bigint NOT NULL; --Vladimir |