Hi Marcel, Please do share. I'm interested to know how you manage to fuse it with swing. I did checkout spring rich client project but there's no solid tutorial to start a project with it.
On 7/4/07, MarcelR <[EMAIL PROTECTED]> wrote:
I didn't succeed in using jpa-hibernate in a Swing application. So, I did like I did in my previous project, using toplink! I copied the appfuse-jpa-hibernate source and changed it to appfuse-jpa-toplink. Only a few changes where actually needed (pom.xml and applicationContext.xml and ?[nr] instead of ? in the jql statements). After that all dao testcases worked!<^O^> But then again to my Swing application: bad luck -> entityManager is closed! mmmmmm, what did I do different in my previous project? Aha -> I used the JpaTemplate. I changed it (needed a few changes) and everything works! So, I've a working version of my Swing application using appfuse-jpa-toplink! Meaby interresting to share it with the community? I can deliver it in a seperate thread.... Greetings, Marcel MarcelR wrote: > > 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#a11418671 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- /fadhli
