本文介绍了Hibernate 5中的TableHiLoGenerator替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在从休眠4迁移到休眠5.我们在项目中使用了"hilo"生成器,使用表作为时序生成器来生成多对多表的ID:

we are migrating from hibernate 4 to hibernate5. We've used "hilo" generator in our project to generate id to many-to-many tables using a table as seguence generator:

<generator class="hilo">
  <param name="table">cw_unique_key</param>
  <param name="column">next_value</param>
</generator>

但是Hibernate 5不支持hilo,当我使用"native"而不是"hilo"时,顺序从0开始,而不是从生成的最高数字开始.您能否让我知道休眠5中是否有"hilo"的替代品?谢谢

but Hibernate 5 does not support hilo and when I use "native" instead of "hilo" the sequesnces start from 0 and not from highest generated number.would you please let me know if there is any replace ment for "hilo" in hibernate 5.thanks

推荐答案

我已将序列生成器从hilo更改为increament,并且对我有用

I've changed the sequence generator from hilo to increament and it worked for me

<generator class="hilo">
  <param name="table">cw_unique_key</param>
  <param name="column">next_value</param>
</generator>

将序列生成器从hilo更改为increament

change sequence generator from hilo to increament

<generator class="increment">
  <param name="table">cw_unique_key</param>
  <param name="column">next_value</param>
</generator>

这篇关于Hibernate 5中的TableHiLoGenerator替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-14 09:19