delpouve wrote:
joib,
even with iterate, the object graph (per row) is not always "loadable" in one generated sql query.
It really depends on your mapping
Oh, I just assumed that rfred999 had a relatively flat structure and the main problem was the large amount of data. Sorry for any confusion.
Quote:
example: A 1--* B 1--* C cannot be loaded in one query "select a as a left FETCH join a.bs left FETCH join bs.c" is not correct
I may be wrong but i've tested many ways to get this 3 level graph in one query (sql generated) ... i didn't manage to do it.
You're right, there is no way to do this with "normal" sql (and thus not with hql) with the standard way to model hierarchies, since to fetch the C:s you need the pk:s of the B:s.
Now, there are a number of ways to do this in a single SQL query. One, if you use Oracle, is to use the (proprietary) CONNECT BY statement. The SQL standard has some kind of WITH RECURSIVE statement which is similar to CONNECT BY, but I don't think any DB supports that :(.
Another way, in the case of trees, is to use the "nested sets model" (Google and you'll find out how to do it). Of course, Hibernate:s collection support doesn't support something like that, but you could of course still map the objects themselves with Hibernate and then build the tree yourself from the flat data returned by a query.
Quote:
And of course, as you said, if there was a solution, the problem of memory would not be solved...
Umm, yes. I think that huge trees (i.e. entire tree won't fit in memory) are very difficult to do efficiently with a RDBMS, and if one encounters them, one ought to spend lots of effort thinking which solution will suck the least (in this case, I think all possible solutions will suck).