0

We have an application where we use table sequencing.Everytime we bounce the server the sequence number( here SEQ_R) in the table acts weird.The sequence number gets incremented by 90000 and at times by 50.Where, the increment should be by 1.

I have to mention that we use MSSQl server.

In our sessions.xml

<sequencing>
  <default-sequence xsi:type = "table-sequence">
  <name> Custom </name>
  <preallocation-size> 80000 </preallocation-size>
  <table> SEQ </table>
  <name-field> SEQ_N </name-field>
  <counter-field> SEQ_R </counter-field>
  </default-sequencing>
</sequencing>

In our mappings.xml

<toplink:sequencing>
  <toplink:default-sequence  xsi:type = "toplink:native">
  <toplink:preallocation-size> 80000 </toplink:preallocation-size>
</toplink:default-sequence>
</toplink:sequencing>

1 Answers1

1

The whole idea of preallocation is that toplink will increment the sequence in the database by 80000, and keeps a counter in memory for the next 80000 items that need a new id. If you bounce the server, the in-memory counter is lost, and toplink reads and updates the database sequence again for the next batch.

If you really want increments by 1, you can use an IDENTITY column in MSSQL. See Toplink Native Sequencing With a Non-Oracle Database Platform

GeertPt
  • 16,398
  • 2
  • 37
  • 61
  • but identity columns are not supported by toplink in our organization. – user1076285 Jan 06 '12 at 20:14
  • I wouldn't worry then :-). No really, as long as the generated id's are different, it's allright. Incrementing by 1 is not really necessary. – GeertPt Jan 06 '12 at 22:41