virtualMeasureMyActionId

virtualMeasureMyActionId

你好,我有以下代码:

@Entity
public class VirtualMeasure extends AbstractMeasure implements Record {

@OneToMany(fetch = FetchType.LAZY, cascade = {CascadeType.REMOVE}, mappedBy
= "virtualMeasureMyActionId.virtualMeasure")
@Access(AccessType.FIELD)
private Set<VirtualMeasureMyAction> vmMyAction;
}

@Entity
@AssociationOverrides({
    @AssociationOverride(name = "virtualMeasureMyActionId.virtualMeasure",
joinColumns = @JoinColumn(name = "virtualMeasureId")),
    @AssociationOverride(name = "virtualMeasureMyActionId.myAction",
joinColumns = @JoinColumn(name = "myActionId")) })
public class VirtualMeasureMyAction implements Record {

/**
 * virtualMeasureViewId : VirtualMeasureViewId
 */
@EmbeddedId
private VirtualMeasureMyActionId virtualMeasureMyActionId;
}


@Embeddable
public class VirtualMeasureMyActionId implements Record {

@ManyToOne(fetch=FetchType.LAZY)
private VirtualMeasure virtualMeasure;


@ManyToOne(fetch=FetchType.LAZY)
private MyAction myAction;
}


我在哪里运行我得到此错误[创建]:javax.persistence.PersistenceException:org.hibernate.HibernateException:找到相同集合的两个表示形式:vmMyAction

最佳答案

问题是休眠会话在您持久化时检测到您在同一会话中有两次相同的集合。

注意不要在您的实体中重复设置器和获取器,并使用merge()update() intead。

10-05 22:13