Hibernate version:
3.2.2
Hi,
if I have a table Parent with PK ParentID, and want to get all of its Children (ParentID FK), what is the recommended approach for getting its children?
* Object navigation, something like:
Parent parent = (Parent)session.load(Parent.class, 1);
Set<Child> children = parent.getChildren();
* or through HQL:
session.createQuery("from Children where ParentID = 1").list()
Are there any performance issues with any of the approaches? Or is it simply a matter of taste?
The first seems more elegant, but if I dont need the Parent in the first place, its also one line of code more as well as more fetching from DB.
thanks!
|