HibernateTemplate opens a session, runs your query, then closes the session for you, hence reducing your code to just one line. Since collections are lazily loaded by default, you will always get an exception if you try to navigate a collection while the session is closed. Making the set load eagerly (like you did) is a solution, but this might have performance problems, since every time you get an exam (or several exams), all of the subjects for this exam (or for each exam in the list you get) will be loaded from the database. Another (better IMHO) solution is to use the open session in view
pattern. I have
a blog post on that subject (pretty old though). Spring also comes with an
OpenSessionInViewFilter, which is pretty useful if your application is a web-app