Hi Patrick,I've been away, so I'm sorry I didn't see this post earlier. I am very busy at the moment, so please also excuse my brief reply!
It's been a while since I looked at this, and in fact in the end we went down a radically different route on this project that didn't need this approach. However, before this departure, I'm pretty sure I managed to get all this to work. Attached is the relevant sitemap listener - I hope it's of some use.
Regards, Robin
HibernateSessionSitemapListener.java
Description: Binary data
On 16 Apr 2008, at 17:17, Patrick Heiden wrote:
Is there any documentation available about usage of EnterSitemapEventListener?OK, maybe it would be helpfull to state the goals I want to achieve.I read [1] and want/have to implement the OpenSessionInViewFilter/ Interceptor for myself. Unfortunately for me, Robin left no results within his discussion ;)So my basic idea/workflow is somewhat 'straightforward' (see [2], too):1. Open Hibernate Session and bind it to the current thread: Session sess = sessionFactory.openSession(); sess.beginTransaction(); //Bind the Session to the current thread/transaction TransactionSynchronizationManager. bindResource(sessionFactory, new SessionHolder(sess)); //Activate transaction synchronization for the current thread. TransactionSynchronizationManager.initSynchronization();Springs TransactionSynchronizationManager comes into play directly, because otherwise calls to getCurrentSession() would throw Exception, because LocalSessionFactory proxies Hibernate SessionFactory (in short: you have to tell what current session- context is).2. render the view3. commit the Session and close it (unbind it from the current Thread, too. Code example yould be found at [2])Hopefully (as Robin stated) this won't breake calls to other sitemaps, but I would guess it wouldn't. Second idea behind that approach (away from Springs OSIV) is to use that as codebase to also implement the long-conversation-pattern and store Hibernates Session inside a users HttpSession.And here I am left with no documentation about the Sitemap- Listeners. E.g. is the HttpSession available, or to be general, wich Objects are available inside those Listeners? I would think, that SitemapEvent.getEnvironment() would always return a HttpEnvironment at runtime, right? If so, the session could be retrieved byObjectModelHelper.getRequest(sitemapEvent.getEnvironment ().getObjectModel()).getSession()Still right? This is the only way I've seen so far.So maybe there is some hidden documentation available for those Listeners, or comments on what I've tried to explain ;)Best greetings, Patrick --Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games!http://games.entertainment.gmx.net/de/entertainment/games/free --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
smime.p7s
Description: S/MIME cryptographic signature
