On executing a stored proc, SharedEntityManagerCreator creates a DeferredQueryInvocationHandler, which creates a temporary EntityManager (if no transactional entity manager is found) and invokes the method (execute), and because it is in the list of queryTerminatingMethods – it appears to have been recently added with #21366 -- it closes the entity manager of the returned query. As such, this:
The only proper way to implement this is to track parameter registrations and then implicitly obtain the corresponding output values on query termination, making the values localy accessible to subsequent getOutputParameterValue calls on the deferred query proxy. Since this is not entirely trivial, I'll turn it into a 5.1 feature.
Generally, the recommendation is indeed to perform such access within a transaction.