【问题标题】:org.hibernate.id.SequenceHiLoGenerator giving wrong idorg.hibernate.id.SequenceHiLoGenerator 给出错误的 id
【发布时间】:2015-03-21 17:53:47
【问题描述】:

从序列中获取错误的值

在 weblogic 11 中,我在 1 个集群下有 2 个管理服务器。我在管理服务器上创建了 1 个数据源并附加到集群。在休眠方面,我正在使用

@XmlTransient
@Id
@Column(name = "id", nullable = false)  
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_NAME")
@SequenceGenerator(name = "SEQ_NAME", sequenceName = "SEQ_NAME")    
public Integer getId() {
    return this.id;
}   

例外:

org.hibernate.event.def.AbstractSaveEventListener saveWithGeneratedId - 生成标识符:41813,使用策略:org.hibernate.id.SequenceHiLoGenerator org.hibernate.util.JDBCExceptionReporter logExceptions - 无法执行 JDBC 批量更新......bla..bla..java.sql.BatchUpdateException:ORA-00001:唯一约束

假设仅在第二台托管服务器上我面临这个问题。
谁能推荐我。

【问题讨论】:

  • 我已经添加了 allocationSize=1,但我仍然面临每 10 万次点击的问题。请建议!

标签: java spring oracle hibernate weblogic


【解决方案1】:

这可能与服务器配置(集群等)无关。

您需要使用 allocationSize 选项。

@SequenceGenerator(name = "productprice_productpriceid_seq", sequenceName = "productprice_productpriceid_seq", allocationSize=1)

请参阅下文了解更多详情。

https://forum.hibernate.org/viewtopic.php?f=1&t=992448

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-03
    • 1970-01-01
    • 2011-11-27
    • 1970-01-01
    相关资源
    最近更新 更多