Two JPA-specific reasons come to mind:
EntityManager is not guaranteed to be threadsafe by the JPA spec. Therefore, portable JPA apps can only use an EM in at most one thread at a time. The idiom of creating a method-local EM and closing it before it goes out of scope encourages stack confinement of EM references.
An EM using the "Extended" Persistence Context Lifetime maintains a single persistence context for its entire existence. This means entities stop automatically detaching on commit()
. Instead they must be manually detached, or else the EM remains responsible for tracking them.
This question is really a JPA-specific version of the old "when to pool objects" question. That's a tough one, but the answer is probably "rarely".
This old developerWorks post by Java concurrency expert Brian Goetz expounds the point. The gist: pools make great sense for costly objects, like database connections. But for short-lived, small, and quick-initializing objects like EntityManager, pooling or some other form of long-term reference retention is a hard sell.
But, it's a general question, so there are bound to be exceptions. Maybe the application is simple or singlethreaded. Then these concerns about threadsafety become moot.