当前位置:编程学习 > JAVA >>

基于JPA的值对象之间的双向关联应该如何写?

各位大师,请教一个问题。
我这里有1个实体,4个值对象(ServicePlanSuite是实体,其他都是值对象),关系分别如下:
ServicePlanSuite 和 ServicePlan 是一对多关系,双向关联
ServicePlan 和 SubservicePlan 是一对多关系,双向关联
SubservicePlan 和 HumanResourceRequirement 以及 FacilityResourceRequirement是一对多关系
之前就算不是双向关联,这样写也会报一个这样一个错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.util.ConcurrentModificationException


@Entity
public class ServicePlanSuite {
@Id
@GeneratedValue
private long id;

@ElementCollection
private List<ServicePlan> servicePlans;


@Embeddable
public class ServicePlan {
    //双向关联用什么注解?
private ServicePlanSuite servicePlanSuite;
    @ElementCollection
private List<SubservicePlan> subservicePlans;


@Embeddable
public class SubservicePlan {
    //双向关联用什么注解?
private ServicePlan servicePlan;
    @ElementCollection
private List<HumanResourceRequirement> humanResourceRequirements;
@ElementCollection
private List<FacilityResourceRequirement> facilityResourceRequirements;


谢谢! --------------------编程问答-------------------- 顶上去啊顶上去
补充:Java ,  Java EE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,