is there a way in Hibernate 3.6 to only load a child entity if a boolean flag in the parent entity is set to true
?
For example:
@Entity
class Parent {
@OneToOne
private Child child;
private boolean loadChild;
}
So if loadChild == false, the child should not be loaded from the db and always be null, otherwise it should be loaded (if available, of course). Currently, the child is loaded eagerly and it would be nice to keep it that way.
Bascially, what we want to prevent here is the actual loading of the child and all the performance impact this may have. It would be easy to load it and then use a getter to return null, but this would have performance impacts by loading a child that is not actually needed.