I have one doubt about "Lazy-loading".
What's the difference between use of @LazyCollection(LazyCollectionOption.FALSE)
and @OneToMany(fetch = FetchType.EAGER)
?
In my application I use two lists, but if I use in this format:
@OneToMany(mappedBy = "consultaSQL", orphanRemoval = true, fetch = FetchType.EAGER,
cascade = CascadeType.ALL)
private List<ParametroSQL> parametros;
@OneToMany(mappedBy = "consulta", orphanRemoval = true, fetch = FetchType.EAGER,
cascade = CascadeType.ALL)
private List<Contato> contatos;
I have this error:
Caused by: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags
I know this occurs because the Hibernate does not allow me to loading two lists at the same time. But if I use this format:
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy = "consultaSQL", orphanRemoval = true,
cascade = CascadeType.ALL)
private List<ParametroSQL> parametros;
@LazyCollection(LazyCollectionOption.FALSE)
@OneToMany(mappedBy = "consulta", orphanRemoval = true,
cascade = CascadeType.ALL)
private List<Contato> contatos;
it works perfectly.
sorry for my English thanks
FetchType.EAGER
that OP describes is still in Hibernate version 5.2. – Dynamotor