Hello all,
We have a tree structure:
Code:
class Location {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "parentLocation", fetch = FetchType.LAZY)
protected SortedSet<Location> childLocations = new TreeSet<Location>();
}
we load all the Locations in one query:
Code:
cache = session.createQuery("from Location");
and then we fill the tree structure like this:
Code:
Location parent;
for (Location loc : cache) {
parent = loc.getParentLocation();
if (parent != null)
parent.addChildLoc(loc);
}
Now the question is, how do we mark the 'childLocations' collection as loaded so Hibernate does not try to run a query to load it?
Many thanks