Lets say I retrieve an entity object that looks like this:
@Entity
public class Mother {
...
@OneToMany(mappedBy = "mother",
targetEntity = Child.class,
fetch = FetchType.LAZY)
public List<Child> getChildren() {
return children;
}
}
When retrieving the above object, I commit the transaction (and close the session associated with the object). Later on in the code, there is a need to retrieve the children. If I wanted to keep the fetch type as LAZY, is there a way to use the Mother object and still be able to call getChildren() to retrieve the children? Or would I have to just bite the bullet and query the children via the key of the Mother?