we have an entity that has a lot of ManyToOne, OneToOne, etc relations which themself have again some relations. For example
@OneToMany(targetEntity = Season.class, cascade = {
CascadeType.ALL
})
@JoinColumn(name = "SEASON_ID")
public List<Season> getSeasons(){...}
(I can not change this).
Those are loaded lazily (by default I think) which is good and we don’t want to change this. Now we have this one case, where we want to find the whole entity eagerly by it's id to return it.
I found a lot of suggestions to change the entity and discussions about wether eager or lazy loading is better, which do not help me at this point, since the entity is out of reach for us. Is there a way to do this, without changing the entity and without having to call every possible getter to initialize the lazy entities (because those are too many)? So for example, the answer to Question 24573877 does not work for me.
Basically I want to say "load the entity eagerly, but just this once".
Currently I'm just doing return em.find(MyEntity.class, contractId)
(I could change this).
Thanks and regards Urr4