0

i cannot succeed to work it out when i trying to do something like that:

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

i keep getting this error massage:

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]

i am new to this and its only work if i delete one of them..

wedew2
  • 5
  • 4

1 Answers1

0

Remove fetchType = FetchType.EAGER and place @LazyCollection(LazyCollectionOption.FALSE) on both collections.

InsertKnowledge
  • 1,012
  • 1
  • 11
  • 17