Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extending the Hibernate session to include the view rendering

 
Cristian Vrabie
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I'm learning to do "pretty" websites with Hibernate as ORM, Spring as IOC and Spring MVC, with Velocity as a template engine for the presentation layer. I recently hit on the standard "lazy loading in view" problem meaning that in Velocity i can't call a getter for which Hibernate should fetch an lazily associated object because by the time the velocity template is rendered the Hibernate Session and thus the transaction is long closed (by the Sping's HibernateTemplate wrapper). Now I noticed that there are several ways to solve this but i'm in doubt what to use. My guts says that i should use AOP to open the transaction at the beginning of the request handle and close it after the the servlet has returned (and thus the view is already rendered). However i have doubts that is the best way to handle this.
What do you think? What do you use?
 
Cristian Vrabie
Ranch Hand
Posts: 71
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic