您好,我有以下代码:
@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
答案 0 :(得分:0)
在vmMyAction中,您同时提供了@OneToMany(mappedBy)
和@Access
。这是休眠状态在异常情况下告诉您的两种表示形式。 Hibernate一次也不支持。
@OneToMany(fetch = FetchType.LAZY, cascade = {CascadeType.REMOVE}, mappedBy
= "virtualMeasureMyActionId.virtualMeasure")
@Access(AccessType.FIELD)
private Set<VirtualMeasureMyAction> vmMyAction;
由于自documentation起,@Access
已被FIELD
弃用,请尝试在没有@Access
批注的情况下进行操作。