2007/8/31, wild_oscar <[EMAIL PROTECTED]>: > > I am making my first web app and I found out today I was doing something > wrong: > > I was building a SessionFactory on my HibernateEntityManager: > > _sessionFactory = configuration.buildSessionFactory(); > > This EntityManager is called on the action so, basically, I was creating a > SessionFactory on each request. > > Searching the web, I panicked! Most people talk about using Spring in > addition to Struts2 + Hibernate. > > Having just started on Struts2, and not having even completed my first web > app, I feel I will lose another week just to understand the basics of Spring > to understand what is needed. > > My question is: what is the most appropriate way of binding the > SessionFactory to the web application? Can someone pinpoint the basics > and/or a tutorial where I can learn this? And how/when is the sessionfactory > closed in the web application?
The "Open session in view" pattern can help you: http://www.hibernate.org/43.html If you are using Spring, there is a ready-made filter: http://www.springframework.org/docs/api/org/springframework/orm/hibernate/support/OpenSessionInViewFilter.html Antonio --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]