First, please try to isolate the getPersistenceManagerFactory
from the methods that prepare its parameters (getProperties
, getClassLoader
), by preparing the parameter values in separate lines before, just to make sure that the issue is with the getPersistenceManagerFactory
method (which is very likely).
The getPersistenceManagerFactory
method does a lot of work so it is expected to be relatively slow. Usually this is not an issue, as it should only be called once per database. The getPersistenceManager
method, which can be called many times per database to create database connections is much faster.
That said, some factors may make getPersistenceManagerFactory
particularly slower, such as having a configuration file with many unused activation keys or having schema with hundreds of complex types.
To analyze your specific case please provide a test case that demonstrates the issue, or at least profiling data that shows where time is spent by this method.