According to
this post, Hibernate complains about 'cannot simultaneously fetch multiple bags' if there are multiple eager-fetched bags to be fetched in the same time as the refering entity.
However, if there are one bag and one set, the error is not reported, but the same problem (cartesian product for the bag) arises. Is this intended?
To be more specific:
This reports 'cannot simultaneously fetch multiple bags':
Code:
@Entity
public class Customer implements Serializable {
@Id
public int customerId;
@OneToMany(fetch=FetchType.EAGER, mappedBy="customer")
public List<Location> locations;
@OneToMany(fetch=FetchType.EAGER, mappedBy="customer")
public List<Invoice> invoices;
}
This does not report 'cannot simultaneously fetch multiple bags', but the actual invoice count is locations.size() times more than real customer's invoice count.
Code:
@Entity
public class Customer implements Serializable {
@Id
public int customerId;
@OneToMany(fetch=FetchType.EAGER, mappedBy="customer")
public Set<Location> locations;
@OneToMany(fetch=FetchType.EAGER, mappedBy="customer")
public List<Invoice> invoices;
}