Okay, I found a way of getting the SessionFactory and starting a new session at the right time.
In a dao a have a property entityManagerFactory, that is set using Spring. Then in a method, e.g. a overriden getAll I first get the SessionFactory and start a new Session: org.hibernate.SessionFactory factory = ((org.hibernate.ejb.HibernateEntityManagerFactory)entityManagerFactory).getSessionFactory(); org.hibernate.Session session = factory.openSession(); And I have a new session started.:) After that I tested my Swing application and bad luck.... still the Session is closed message. So what is closing these sessions, before all work is done.....? Anybody any idea? MarcelR wrote: > > How do I get the sessionFactory within appfuse2? > Because that's the property HibernateInterceptor needs.... > > > Sanjiv Jivan wrote: >> >> So it appears you just need a single JVM Swing app and not a web app. You >> should be able to use Hibernate's lazy loading features. Since you're >> modifying AppFuse to no longer be a web app, you'll have to use >> HibernateInterceptor instead of the OpenSessionInViewFilter in order to >> have >> the container seamlessly manage Hibernate sessions. >> >> See >> >> http://www.springframework.org/docs/api/org/springframework/orm/hibernate/HibernateInterceptor.html >> >> Sanjiv >> >> On 6/29/07, MarcelR <[EMAIL PROTECTED]> wrote: >>> >>> >>> Yes, I had no problems in an Swing application where lazy loading was >>> used >>> in >>> one single JVM (sun/jrockit). (That's what I want to use now as well >>> with >>> appfuse2.) >>> Actually, I want to show database activity to the user and that's hard >>> when >>> lazy loading is used. >>> >>> >>> http://www.oracle.com/technology/tech/java/oc4j/ejb3/howtos-ejb3/howtooutofcontainer/doc/how-to-ejb30-out-of-container.html >>> See also : >>> TopLink has always supported Lazy Loading through it's indirection >>> feature. >>> The EJB 3.0 specification provides for transparent lazy loading. In >>> other >>> words, objects referenced across relationships can be loaded on an as >>> needed >>> basis. >>> >>> Marcel >>> >>> >>> >>> Sanjiv Jivan wrote: >>> > >>> > Transparent lazy loading across client - server boundaries is not a >>> > trivial >>> > problem. There's been a lot of discussion on this (on the Spring and >>> > Hibernate lists) and suggestons of using a smart proxy but there's no >>> > implementation of those concepts. Are you sure that Toplink was able >>> to >>> > provide transparent lazy loading across JVM's? If so, you should >>> probably >>> > stick with using toplink (and I'll check it out too). >>> > >>> > Sanjiv >>> > >>> > >>> > >>> > >>> >>> -- >>> View this message in context: >>> http://www.nabble.com/Appfuse-Core-%2B-Swing%3A-Session-is-closed-tf3987393s2369.html#a11358190 >>> Sent from the AppFuse - User mailing list archive at Nabble.com. >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [EMAIL PROTECTED] >>> For additional commands, e-mail: [EMAIL PROTECTED] >>> >>> >> >> > > -- View this message in context: http://www.nabble.com/Appfuse-Core-%2B-Swing%3A-Session-is-closed-tf3987393s2369.html#a11368180 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
