【问题标题】:JPA 2(hibernate) insertion duplicates of child collection while persisting the parent.WHat is the workaround as of todayJPA 2(hibernate)在保留父集合的同时插入子集合的重复项。截至今天的解决方法是什么
【发布时间】:2012-10-19 18:38:46
【问题描述】:

我相信很多人都经历过这个问题,在hibernate jirastackOV 1stackOV 2 上明确表达了这个问题。我使用 hibernate 4.0.1.Finalspring-data-jpa 1.1.0.M1 。相关的 POJO 实际上是 ID 生成的,所以我想知道 equalshashcode 的具体实现是否可以帮助解决问题,或者我必须找到另一种生成 ID 的方法

感谢您阅读本文。

【问题讨论】:

  • 如何生成id?当我使用数据库机制(自动增量或序列)时,我永远不会遇到任何问题。

标签: java hibernate jpa duplicates


【解决方案1】:

没关系!!

我有一个独特的领域是问题的根源。顺便说一句,我使用身份(自动增量)

@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)

【讨论】:

    猜你喜欢
    • 2011-03-15
    • 2011-12-15
    • 2014-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 1970-01-01
    • 2018-02-10
    相关资源
    最近更新 更多