This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I think I'm missing some trivial aspect of Hibernate, but I'm having extreme problems with LazyInitializationExceptions. I've been haing trouble in two places. The first is in a rather simple test case of the service layer. The second is in view code (and yes, I'm using open session in view filters).
My test code:
findById is identical to the code in the Java Persistence with Hibernate book:
If I pass in a lock=true value, I don't get the lazy initialization exception, if I pass in false I get the error. From my understanding, either lock moe should work.
I'm using standard JPA annotations to inject EntityManagers into the services.