Java 当我需要使用两列时,如何使用@oneToMany

Java 当我需要使用两列时,如何使用@oneToMany,java,spring,hibernate,Java,Spring,Hibernate,当我试图做这样的事情时,我无法成功地解决它: @OneToMany(mappedBy = "company", fetch = FetchType.EAGER) private List<Coupon> coupons; @OneToMany(mappedBy = "company", fetch = FetchType.EAGER) private List<Employee> employes; 如果我删除其中一个,我对这一点和它的唯一工作是陌生的。删除fe

当我试图做这样的事情时,我无法成功地解决它:

    @OneToMany(mappedBy = "company", fetch = FetchType.EAGER)
private List<Coupon> coupons;
@OneToMany(mappedBy = "company", fetch = FetchType.EAGER)
private List<Employee> employes;

如果我删除其中一个,我对这一点和它的唯一工作是陌生的。

删除
fetchType=fetchType.EAGER
并将
@LazyCollection(LazyCollectionOption.FALSE)
放在两个集合上

WARNING: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'companyDBDAO': Unsatisfied dependency expressed through field 'getlocalSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'getLocalSessionFactory' defined in config.SpringConfig: Invocation of init method failed; nested exception is org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags: [beans.Company.coupons, beans.Company.employes]