Re: JPA EntityManager storage

2009-06-10 Thread Adrian Merrall
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

Re: JPA EntityManager storage

2009-06-10 Thread wfaler
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

Re: JPA EntityManager storage

2009-06-10 Thread Frank Tegtmeyer
Hi Adrian, - Are you setting your entity manager on the threadlocal during onBeginRequest by putting it on or relying on the inititalvalue for the threadlocal. I think you hit the problem here. The example I used (in German at http://rattlab.net/2008/10/persistenz-fur-den-feedreader/)

Re: JPA EntityManager storage

2009-06-10 Thread James Carman
On Wed, Jun 10, 2009 at 11:34 AM, Frank Tegtmeyerf...@fte.to wrote: I think you hit the problem here. The example I used (in German at http://rattlab.net/2008/10/persistenz-fur-den-feedreader/) implies that every Request uses its own thread and I never expected threads to be reused. I used

Re: JPA EntityManager storage

2009-06-10 Thread Luther Baker
http://faler.wordpress.com/2009/04/30/building-a-more-scalable-open-session-in-view/ Nice post. For some reason I thought Hibernate's Session could be configured to do this sort of thing intrinsically (ie: starting and ending tx are essentially noops unless something actually happened - part of

Re: JPA EntityManager storage

2009-06-10 Thread Luther Baker
Indeed, it can seem *spooky* to start writing code at the ThreadLocal level ... but remember, threads are created, assigned, collected and reused by the server - unless explicitly created by the application (which is highly discouraged), they are managed by the server. That said, the server

Re: JPA EntityManager storage

2009-06-09 Thread Frank Tegtmeyer
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

Re: JPA EntityManager storage

2009-06-09 Thread James Carman
It sounds to me like you're spending too much time fighting. You could have spent this time learning Spring (it's not that hard for what you want to do) and you'd be a happy camper right now. There's a reason so many folks use it. It works. On Tue, Jun 9, 2009 at 7:48 AM, Frank

Re: JPA EntityManager storage

2009-06-09 Thread Martin Makundi
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. What do you mean you CHECK for open transactions? Although I created a new EntityManager  in onBeginRequest() I

Re: JPA EntityManager storage

2009-06-09 Thread James Carman
On Tue, Jun 9, 2009 at 8:00 AM, Martin Makundimartin.maku...@koodaripalvelut.com wrote: Haven't seen any benefits to Spring, yet. Well, you're in the minority. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For

Re: JPA EntityManager storage

2009-06-09 Thread Luther Baker
Maybe this link will help: https://www.hibernate.org/43.html in the class JpaUtil. I don't like this approach because it depends on the implicit assumption that each request is handled in a thread (this depends on Wicket implementation details, therefor I dislike it) This assumption is not

Re: JPA EntityManager storage

2009-06-09 Thread Luther Baker
Careful, that link got mangled: goog_1244383468413https://www.hibernate.org/43.html Hope this helps, -Luther On Tue, Jun 9, 2009 at 7:10 AM, Luther Baker lutherba...@gmail.com wrote: Maybe this link will help: https://www.hibernate.org/43.html in the class JpaUtil. I don't like this

Re: JPA EntityManager storage

2009-06-09 Thread Martin Makundi
On Tue, Jun 9, 2009 at 8:00 AM, Martin Makundimartin.maku...@koodaripalvelut.com wrote: Haven't seen any benefits to Spring, yet. Well, you're in the minority. That doesn't necessary mean I am wrong ;) All the fancy thins happening with spring, I just leave them out which results in a more

Re: JPA EntityManager storage

2009-06-09 Thread James Carman
On Tue, Jun 9, 2009 at 8:16 AM, Martin Makundimartin.maku...@koodaripalvelut.com wrote: That doesn't necessary mean I am wrong ;) All the fancy thins happening with spring, I just leave them out which results in a more streamlined solution. Ok, there are some integrations which are easily

Re: JPA EntityManager storage

2009-06-09 Thread Martin Makundi
Yes, but the integration library is battle-tested and proven to be useful. Yesyes.. I would use it if I was integrating something big. However, attaching Hibernate is easier via vanilla java than via Spring configuration. ** Martin

Re: JPA EntityManager storage

2009-06-09 Thread James Carman
On Tue, Jun 9, 2009 at 8:26 AM, Martin Makundimartin.maku...@koodaripalvelut.com wrote: Yesyes.. I would use it if I was integrating something big. However, attaching Hibernate is easier via vanilla java than via Spring configuration. Good luck managing your transactions yourself (if you're

Re: JPA EntityManager storage

2009-06-09 Thread Martin Makundi
Good luck managing your transactions yourself (if you're not using a JTA-enabled container) Well.. with wicket it's easy when the transactions are request-scoped. It's a different ballgame somewhere else.. but then we can have EJB3 or something. ** Martin

Re: JPA EntityManager storage

2009-06-09 Thread James Carman
On Tue, Jun 9, 2009 at 8:39 AM, Martin Makundimartin.maku...@koodaripalvelut.com wrote: Well.. with wicket it's easy when the transactions are request-scoped. It's a different ballgame somewhere else.. but then we can have EJB3 or something. Yes, but not all transactions are request-scoped.

Re: JPA EntityManager storage

2009-06-09 Thread Luther Baker
attaching Hibernate is easier via vanilla java than via Spring configuration. attaching Hibernate is [even eaiser with Guice]! :) On Tue, Jun 9, 2009 at 7:59 AM, James Carman jcar...@carmanconsulting.comwrote: On Tue, Jun 9, 2009 at 8:39 AM, Martin Makundimartin.maku...@koodaripalvelut.com

Re: JPA EntityManager storage

2009-06-08 Thread Adrian Merrall
I try to keep my UI logic, my business logic, and my persistence strategy separate. Putting the EntityManager in the Request means you have to pass the Request around into your business logic layer. By putting it in a ThreadLocal, the UI and business layers can be blissfully unaware of its

Re: JPA EntityManager storage

2009-06-05 Thread Martin Makundi
I would just use a ThreadLocal variable in some static EntityManagerUtil/Helper class. ** Martin 2009/6/5 Frank Tegtmeyer f...@fte.to: Hi, would the Request object be a good place to store a JPA EntityManager? It would be created in onBeginRequest() and destroyed in onEndRequest() of the

Re: JPA EntityManager storage

2009-06-05 Thread Martin Makundi
I don't like this approach because it depends on the implicit assumption that each request is handled in a thread  (this depends on Wicket implementation details, therefor I dislike it) Don't fall into the trap of premature optimization! ** Martin

Re: JPA EntityManager storage

2009-06-05 Thread Frank Tegtmeyer
Don't fall into the trap of premature optimization! Hm. Maybe I'm in this trap already. But what is wrong with binding a resource directly to the request when it is used exactly for the lifetime of the request? For me this only sounds logical compared to the pragmatic approach using a

Re: JPA EntityManager storage

2009-06-05 Thread Martin Makundi
But what is wrong with binding a resource directly to the request when it is used exactly for the lifetime of the request? a) sounds complex b) you are BINDING it. The less you have dependencies on _specific_ bound components, the better.. in general. ** Martin

Re: JPA EntityManager storage

2009-06-05 Thread Christopher L Merrill
Frank Tegtmeyer wrote: would the Request object be a good place to store a JPA EntityManager? It would be created in onBeginRequest() and destroyed in onEndRequest() of the RequestCycle object. You may find these of interest:

Re: JPA EntityManager storage

2009-06-05 Thread Frank Tegtmeyer
You may find these of interest: http://javanotepad.blogspot.com/2007/08/managing-jpa-entitymanager-lifecycle.html Yes, if I need that level of flexibility (which I don't need). I pay with complexity of the implementation. Anyway, this is a nice lesson, thanks for the link! Regards, Frank

Re: JPA EntityManager storage

2009-06-05 Thread Martin Makundi
To stress this point: EntityManager should not be visible in Wicket UI Eclipse Project namespace (classpath). ** Martin 2009/6/5 Frank Tegtmeyer f...@fte.to: Putting the EntityManager in the Request means you have to pass the Request around into your business logic layer. Ok, that's a