I have a parent like this:
@Entity @Table(name="parent") public class Parent { private List<Child> childs; private List<AnotherChild> anotherChilds; @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY) public List<Child> getChilds() { return childs; } @OneToMany(mappedBy = "parent", fetch = FetchType.LAZY) public List<AnotherChild> getAntoherChilds() { return anotherChilds; } //Getters and Setters ommited } And two children like this
@Entity @Table(name="child") public class Child { private Parent parent; @ManyToOne @JoinColumn(name = "column_name") public Parent getParent() { return patern; } } @Entity @Table(name="another_child") public class AnotherChild { private Parent parent; @ManyToOne @JoinColumn(name = "column_name") public Parent getParent() { return patern; } } I have a named query which gets all the Parents, but this is also loading all the children? How can I stop the children for automatically loading?
Thanks.