Problem in generating the Primary Key using a Sequence
Amit Chauhan
Greenhorn
Joined: Jun 26, 2007
Posts: 27
posted
0
Hi All , I am trying to persist an object and also generating the primary key using a default sequence . But the problem is that the Primary key is getting incremented by 2 instead of 1 . My code looks like this : ----------------------------------------------------------------------------------------------------------------------------
What is your class mapping look like. When you say the default sequence, do you mean something like "hibernate_seq" and then therefore more than one object is mapped to generating the PK from that sequence table, such that I insert one record in table A it gets id 1, then insert one record into table B it gets id 2, then insert again into table A and it gets id 3?
Or do you have it mapped for objects A mapped to Table A and Sequence "a_seq" and for Object B mapped to Table B and sequence "b_seq"