Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何为Spring和Hibernate实现多对多?_Java_Spring_Hibernate - Fatal编程技术网

Java 如何为Spring和Hibernate实现多对多?

Java 如何为Spring和Hibernate实现多对多?,java,spring,hibernate,Java,Spring,Hibernate,我想在Java Spring和Hibernate中实现这种关系: 在我的GnrlOrgChargeCode类中,我有: @OneToMany (targetEntity=IOrgChargeCodeCond.class, mappedBy="gnrlOrgChargeCode", fetch=FetchType.EAGER) private List <IOrgChargeCodeCond> orgChargeCodeConds; @ManyToOne pri

我想在Java Spring和Hibernate中实现这种关系:

在我的GnrlOrgChargeCode类中,我有:

@OneToMany (targetEntity=IOrgChargeCodeCond.class, mappedBy="gnrlOrgChargeCode", fetch=FetchType.EAGER)
private List <IOrgChargeCodeCond> orgChargeCodeConds;
@ManyToOne
private IGnrlOrgChargeCode gnrlOrgChargeCode;
    
@OneToMany
private List <IBillingCondition> billingCondition;
在我的BillingRule课程中:

@ManyToOne
private BillingRule billingRule;
@OneToMany(mappedBy = "billingRule")
private List<OrgChargeCodeRule> orgChargeCodeRules;
假设gocc.orgId有效并且gocc中有行


请帮忙。谢谢。

我想问题出在这里:

OrgChargeCodeCond:
@OneToMany
private List <IBillingCondition> billingCondition;

BillingCondition:
@OneToMany
private List <OrgChargeCodeCond> orgChargeCodeCond;
OrgChargeCodeCond:
@独身癖
私有列表计费条件;
计费条件:
@独身癖
私人名单或信用证;
所以你实际上是在两个方向上定义了@OneToMany关系。从图表中,计费条件应为@manytone。 如果您需要多对多关系,可以尝试在两侧使用@ManyToMany注释。但我不推荐它,最好添加另一个实体并在两者之间创建@OneToMany


另一个“专业提示”,看看,你可以创建或导入你的模式,并取出你的Hibernate实体。

我已将BillingCondition.java更改为@Manytone private IOrgChargeCodeCond或ChargeCodeCond。但错误依然存在。请帮助。您是否也将字段从列表更改为单个实例?调试真的很困难,但请查看Bootify,它可以帮助您(无需注册)是的,我做到了。我将列表更改为“private IORGCHARGECODCOND或CHARGECODECOND”。我是否也应该将OrgChargeCodeCond.java的billingCondition更改为single instance?请帮忙。谢谢
select from GnrlOrgChargeCode gocc 
join OrgChargeCodeRule occr 
join BillingRule br 
join OrgChargeCodeCond occc 
join BillingCondition bc 
where gocc.orgId = ? 
OrgChargeCodeCond:
@OneToMany
private List <IBillingCondition> billingCondition;

BillingCondition:
@OneToMany
private List <OrgChargeCodeCond> orgChargeCodeCond;