I have a one to many relationship on a bunch of my entities. However I do not always want to have a value defined for the children. Since it can be a one to many it could be null.
When I do not create the child object my tests fail with a Referential integrity constraint violation.
I tried adding nullable true to the join however that did not seem to resolve the issue.
@JoinColumn(name = "image_relation")
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany
private List<Image> productImageGroup;
I tried using fetch type of eager and got a different error.
@JoinColumn(name = "product_item_relation")
@OneToMany(fetch=FetchType.EAGER)
private List<ProductItems> productItemGroup;
Throws:
Caused by: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags