• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in creating a new record

 
Jim Patrick
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

i have an action to create a new record in oracle 10g database..
but each time i create a new record, for example,

suppose there are some records in my table and the last record's id is 101,
then if i create a new record, it shows that its id is 121.

why is it so? why does it create a record which is the id of the last record+20 ?

here is my action class:




and this is my hibernate mapping:




Thanks in advance for any inputs...
[ December 03, 2007: Message edited by: Jim Patrick ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

suppose there are some records in my table and the last record's id is 101,
then if i create a new record, it shows that its id is 121.

why is it so? why does it create a record which is the id of the last record+20 ?

Hibernate is just using the sequence you specify, so presumably either the sequence has an increment by value of 20, or empidseq.nextval is being called lots of times by some other process.
 
Jim Patrick
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:

Hibernate is just using the sequence you specify, so presumably either the sequence has an increment by value of 20, or empidseq.nextval is being called lots of times by some other process.


Thanks paul...

has it got anything to do with cache size?
i checked the empidseq table in my database(oracle 10g) and in the cache options, the cache size is specified as 20.. i didnt specify the size myself...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah yes, I'd forgotten about that! A sequence number cache size of 20 is the Oracle default. You are supposed to lose sequence numbers, its just how Oracle works. Oracle uses water marking, so it caches the last used sequence number, plus the water mark. When the last used value equals the water mark, Oracle writes changes and moves the watermark. This is done to prevent constants updates on the sys.seq$ table; in a database that is under a decent load you'll notice this bottleneck pretty quickly. So to guarentee your sequence behaves using you increment value, you could create your sequence with nocache specified (which is bad for the reasons above).
 
Jim Patrick
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
Ah yes, I'd forgotten about that! A sequence number cache size of 20 is the Oracle default. You are supposed to lose sequence numbers, its just how Oracle works. Oracle uses water marking, so it caches the last used sequence number, plus the water mark. When the last used value equals the water mark, Oracle writes changes and moves the watermark. This is done to prevent constants updates on the sys.seq$ table; in a database that is under a decent load you'll notice this bottleneck pretty quickly. So to guarentee your sequence behaves using you increment value, you could create your sequence with nocache specified (which is bad for the reasons above).


thanks a lot..Paul..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic