Hi,
Ever since Hibernate 3, associations have been lazy by default. I have a code base with a pretty extensive set of data objects, with virtually every association modeled as non-lazy, and I'm looking in to changing that because I want to interact with Hibernate in a more standard way.
The reason we do this is because there's two basic use cases in our application. One works well with lazy associations: there's a Session available, and we can rely on Hibernate to fetch things when needed. The other doesn't: objects need to be read completely, and sent elsewhere. They'll be used at some later date at a time when there is no Session available (or perhaps even a database connection at all), and therefore must have all their associations loaded right now, even though that's going to be many individual SQL queries.
The way I think about this, that means that I'd want to request an object from a session, and say 'load completely', which would force non-lazy initialization for every association. As far as I know, there's now way to do this at the query level, but I'm hoping that someone here knows different?
Thanks,
Chris
|