【问题标题】:Why would the default allocationSize property for a @SequenceGenerator annotation in JPA be 50?为什么 JPA 中 @SequenceGenerator 注释的默认 allocationSize 属性为 50?
【发布时间】:2013-01-15 16:45:10
【问题描述】:

当我意识到 @SequenceGenerator 的 thge allocationSize 属性的默认值为 50 时,我正在查看休眠源。

根据来源...

/**
 * (Optional) The amount to increment by when allocating
 * sequence numbers from the sequence.
 */
int allocationSize() default 50;

知道为什么这是 50 而不是 1 吗?这是否意味着默认情况下您的主键将变为 1、50、100、150 等?在我看来,增加 1 更常见并且更有意义?

【问题讨论】:

    标签: hibernate jpa sequence


    【解决方案1】:

    我今天下午偶然发现this discussion 在那里你可以找到来自Emmanuel Bernard 的帖子,指出这是一个效率问题,而不是人们期望的行为。

    【讨论】:

      猜你喜欢
      • 2016-09-09
      • 2016-12-21
      • 2015-07-23
      • 2016-05-23
      • 2011-02-05
      • 2012-09-26
      • 1970-01-01
      • 2019-07-06
      • 1970-01-01
      相关资源
      最近更新 更多