ok. Thanks For me could be a good idea.
2014-11-07 11:54 GMT+01:00 Christian Schneider <ch...@die-schneider.net>: > We need to keep the EntityManager open for the duration of the session the > developer expects. So for example when you have cascaded transactional > calls then only when such a cascade is left we can savely close and delete > the EntityManager. So for transaction scope Required we could detect if an > EntityManager is already present and only create and delete it if it was > not present. > > My sample code does not reflect this as it is simplified. I am aware of > course that a real solution will look a bit more complex. > > The main difference would be that the EM as well as transaction lifecycle > would not be handled in the EntityManager wrapper but instead in the > transactional interceptor. > So the wrapper would become simpler. > > I think we could also provide the interceptor before and after logic as a > service. So not only our blueprint namespace could use it but also > integrations into other injection frameworks. > > Christian > > > On 07.11.2014 11:05, Giuseppe Gerla wrote: > >> But this is not true with your code. If you after the call close the >> EntityManager and call remove on ThreadLocal, you have several >> EntityManager for the same Thread >> >> >> >> >> >> 2014-11-07 10:50 GMT+01:00 Christian Schneider <ch...@die-schneider.net>: >> >> Hi Giuseppe, >>> >>> I think the ThreadLocal is necessary. We want to make sure that calls on >>> the same thread always go to the same EntityManager. >>> >>> Christian >>> >>> On 07.11.2014 10:29, Giuseppe Gerla wrote: >>> >>> Thanks Christian >>>> I think I understand. So before each transactional method (not only >>>> persist) you create an EntityManager and then you close it. >>>> I'm not sure that you can simplify the JTAEntityManagerHandler class. >>>> I think that the only change that we can do is to simplify the pool >>>> management removing the ThreadLocal and the using a simple resourcepool. >>>> If you want I can try to prepare an example on my trunk. >>>> >>>> >>>> >>>> >>>> -- >>> Christian Schneider >>> http://www.liquid-reality.de >>> >>> Open Source Architect >>> http://www.talend.com >>> >>> >>> > > -- > Christian Schneider > http://www.liquid-reality.de > > Open Source Architect > http://www.talend.com > >