title: How to get rid of LazyInitializationException with Wicket JPA/Hibernate integration (with Spring)
body: <p>i'm developing an application using Wicket as the view layer and JPA(Hibernate) as ORM. building the UI has been fun (even with ajax) using Wicket. My problem comes from integrating the persistent objects on edit pages (readonly pages are no problem using a LoadadableDetachableModel).</p>
  
  <p>I'm using the OSIV filter from spring to provide an open session for the view. But, as i keep the domain objects (the @Entity mapped classes) in the edit pages, i get the dreaded Lazy loading excetion when i access properties of them in ajax callbacks.</p>
  
  <p>i don't really want to go down the DTO / VO road, as i think it would only bloat the code and requires me to write lots of boiler-plate code.</p>
  
  <p>One idea was to use the model objects in the view, merge the passed in object with the current hibernate session and access all getters to fully initialize the object. after this, the object would be stored in the view (seesion) and become detached. Upon save, i would re-merge it and commit the change.</p>
  
  <p>Would this be an recommended way? Are there better solutions? Strange enough, most books / blogs / howtos completely ignore such issue. </p>
  
  <p>What transaction management would you suggest? Right now i use @Transaction at the service layer. How would that change if i use other ways of accessing storing the data across hibernate sessions?</p>
  
  <p>Any pointers / Links are welcomed as i'm kind of lost here.. </p>
  
  <p>thanks in advance</p>