On Aug 24, 2006, at 1:50 PM, Andrus Adamchik wrote:
2. What's supposed to happen when you try to use a CM tx scoped EM
outside a JTA tx? Section 5.6.1 seems to imply we aren't supposed
to just throw an exception, but section 5.9.1 seems to imply there
is no provider EM in back of the CM EM to do any work without a
JTA tx. Are we supposed to create and close a provider EM for
each call outside a tx?
Good question... I have no idea.
From what I understand, yes.
- How heavyweight are EntityManagers?
I guess this could be implementation specific, but they are
lightweight in Cayenne, and I assume they are lightweight in other
providers as well.
Is it more efficient to create a new one or pool them?
While the spec provides some leeway (see below), container with
pluggable provider has no way of knowing the best strategy. My vote
is to avoid pooling EntityManagers by default.
+1 If it later becomes an issue we can introduce pooling.
My guess is that most providers are pooling under the covers since
the largest user group will be unmanaged servlets which don't do app
level pooling.
-dain