toplink 排序按预分配大小跳转
我们有一个使用表排序的应用程序。每次我们反弹服务器时,表中的序列号(此处为 SEQ_R)都会表现得很奇怪。序列号会增加 90000,有时会增加 50。其中,增量应该是 1。
我不得不提一下,我们使用 MSSQl 服务器。
在我们的session.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>
在我们的mappings.xml中
<toplink:sequencing>
<toplink:default-sequence xsi:type = "toplink:native">
<toplink:preallocation-size> 80000 </toplink:preallocation-size>
</toplink:default-sequence>
</toplink:sequencing>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
预分配的整个想法是,toplink 将数据库中的序列增加 80000,并在内存中为接下来需要新 id 的 80000 个项目保留一个计数器。如果您退回服务器,内存中的计数器就会丢失,并且 toplink 会在下一批中再次读取并更新数据库序列。
如果您确实希望增加 1,则可以在 MSSQL 中使用 IDENTITY 列。请参阅使用非 Oracle 数据库平台的 Toplink 本机排序
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