Re: [S2] Where to put hibernate's SessionFactory?
wild_oscar wrote: I've created an Interceptor that takes care of creating a SessionFactory and putting it in the Application Context map. I have a question, though, about the application context. Does this mean the Session Factory is shared among every session of the application, regardless of the internet user that is accessing it? What would happen if I wanted Yes, by definition, since application scope is shared accross all requests and sessions. For a Hibernate session factory that's probably what you want in most cases. more than one connection to databases (e.g: one for authorization and authentication, another for an e-shop)? The presumably you'd have a session factory configured for each connection; I'm not sure. How to handle connections to multiple databases is a Hibernate usage issue. Browse the Hibernate documentation and/or ask on their forums. L. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Where to put hibernate's SessionFactory?
Thank you. I've implemented the non IoC version of it, which I found to be almost the same as in http://struts.apache.org/2.0.9/docs/non-ioc-version-of-opensessioninviewinterceptor.html http://struts.apache.org/2.0.9/docs/non-ioc-version-of-opensessioninviewinterceptor.html Antonio Petrelli-3 wrote: 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] -- View this message in context: http://www.nabble.com/-S2--Where-to-put-hibernate%27s-SessionFactory--tf4361648.html#a12512623 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Where to put hibernate's SessionFactory?
I've created an Interceptor that takes care of creating a SessionFactory and putting it in the Application Context map. I have a question, though, about the application context. Does this mean the Session Factory is shared among every session of the application, regardless of the internet user that is accessing it? What would happen if I wanted more than one connection to databases (e.g: one for authorization and authentication, another for an e-shop)? Kevin Lawrence-3 wrote: I'm a newbie too - so I can't tell you the best way - but what I did is lazily create one and put it in the the application context. Kevin http://www.junitfactory.com Just went live with Struts2 wild_oscar wrote: 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? Thank you! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/-S2--Where-to-put-hibernate%27s-SessionFactory--tf4361648.html#a12474755 Sent from the Struts - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Where to put hibernate's SessionFactory?
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]
Re: [S2] Where to put hibernate's SessionFactory?
I'm a newbie too - so I can't tell you the best way - but what I did is lazily create one and put it in the the application context. Kevin http://www.junitfactory.com Just went live with Struts2 wild_oscar wrote: 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? Thank you! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]