小编fie*_*die的帖子

Hibernate为新的子实体生成ghost条目

我对Hibernate有一个奇怪的(对我而言)问题,我无法理解.下面的代码是我试图使用一个额外的实体CaseToSuggestion和Case作为我的聚合根,在实体Case和Suggestion之间使用属性建模ManyToOne关系:

@Entity
@Table(name = "sga_cases")
public class Case {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

    // Business key
    @Column(name = "caseid", unique = true, nullable = false)
    private String caseId;

    ...

    @OneToMany(mappedBy = "associatedCase", orphanRemoval = true, cascade = CascadeType.ALL)
    private Set<CaseToSuggestion> associatedSuggestions = new HashSet<CaseToSuggestion>();

    ...
}


@Entity
@Table(name = "sga_suggestions")
public class Suggestion {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int id;

    @Column(name = "suggestionid", unique = true, nullable = false)
    private String suggestionId;

    @Column(name = "localizationkey", nullable …
Run Code Online (Sandbox Code Playgroud)

java hibernate

5
推荐指数
1
解决办法
239
查看次数

标签 统计

hibernate ×1

java ×1