Hi,
thank you for your quick answer.
You are right with the difference in session.load(...) vs session.get(...).
It solves the LazyInitializationException on the Publisher object.
But nevertheless an exception is thrown when I access the book relationship.
I have changed the code to:
Code:
...
Publisher loadedPublisher = (Publisher) session.get(Publisher.class, publisherId);
Hibernate.initialize(loadedPublisher);
tx.commit();
Set<Book> books = loadedPublisher.getBooks();
And the Exception is:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: crud.book.model.Publisher.books, no session or session was closed
Any ideas? Again, I can solve this by doing an explicit left join fetch on the relationship property, but what is the lazy attribute in mapping file for if it changes nothing in the behavior of the framework?