Regarding Open Session in View type patterns for JPA as Adrian mentioned, there are slides from the London Wicket event here: http://londonwicket.googlecode.com/files/LondonWicket-OpenSessionInView.pdf http://londonwicket.googlecode.com/files/LondonWicket-OpenSessionInView.pdf
There is a further improved version of the Open Session in View for Wicket and JPA that provides better performance and scalability here: https://wicket-rad.svn.sourceforge.net/svnroot/wicket-rad/trunk/wicket-rad-jpa/ https://wicket-rad.svn.sourceforge.net/svnroot/wicket-rad/trunk/wicket-rad-jpa/ (not yet in any maven repo, but the code is mature, battle tested and there for the taking). It is quite easy to have a very detrimental effect on performance and scalability using the Open Session in View pattern if you are not aware of the pitfalls, which I have explained here: http://faler.wordpress.com/2009/04/30/building-a-more-scalable-open-session-in-view/ http://faler.wordpress.com/2009/04/30/building-a-more-scalable-open-session-in-view/ (the source I'm pointing to above has taken these pitfalls into consideration). / Wille Adrian Merrall wrote: > > Frank, > Regarding your question (without joining the IOC holy-war), your > experience > seems odd. The wicket rad project has examples of this approach and from > memory there are some slides from a wicket presentation in London on the > same thing floating about so I think we can conclude it is a common > approach. > > I actually like this approach and given that the wicket guys gave us the > request cycle and such an easy way to implement our own, it seems a very > "wicket" way to handle the problem as long as it fits your use case (all > transactions inside the request). > > A couple of general thoughts - apologies if these are too basic. > > - Are you sure your Entity manager is being opened correctly and set in > the > threadlocal in onBeginRequest. If you are putting it in there correctly, > the only way it is coming out is if you take it out. > > - Any chance the same entity manager is getting closed somewhere else in > the > code. > > - Are you setting your entity manager on the threadlocal during > onBeginRequest by putting it on or relying on the inititalvalue for the > threadlocal. This is only called once per thread on the first get. As > threads are re-used, only the first requestcycle using a thread will call > this. > > - Are you over-riding onRuntimeException as well as onEndRequest and > handling the threadlocal cleanup in both places. > > - Leaving entity managers lying around doesn't seem ideal. I think it is > better to clean them up and rely on pooling. Using dbcp with Apache > openJpa > gives a spectacular speedup. > > As above, apologies if this is all too basic, just brain dumping before > bed > time. > > Cheers, > > Adrian, > Auckland, NZ. > > On Tue, Jun 9, 2009 at 11:48 PM, Frank Tegtmeyer <f...@fte.to> wrote: > >> >> > Well when it comes to EntityManagers be sure to close, commit and >> > clear your threadlocal instance after your service request cycle. >> >> Exactly that didn't work for me. I checked for open transactions, >> closed them, closed the EntityManager and even released it by setting >> the ThreadLocal variable to null. >> Although I created a new EntityManager in onBeginRequest() I >> constantly got errors during form processing because of not existing >> EntityManager. I solved this by leaving EntityManager there after the >> request and checking for its existence at the begin of the request. >> >> Any ideas about this? >> >> Regards, Frank >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > > -- View this message in context: http://www.nabble.com/JPA-EntityManager-storage-tp23888325p23962203.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org