Speeding up the creation of an Entity Manager #2112
Replies: 1 comment
-
"eclipselink.validation-only" was created for validation only purposes, not for a usable EntityManagerFactory/EntityManager creation. It was added I believe to validate the mappings, but a usable persistence context needs the connections initialized. "eclipselink.target-database" is certainly helpful as the auto config will use the driver metadata to determine the connected database and then the platform used. I can't say how much overhead auto db platform lookups adds, but it is unnecessary overhead if you know the platform you want it to be using anyway - and you can override it in properties for testing should you wish to run against an in-memory or other database. Otherwise, I'd say the best option is to try to setup the EMF and obtain an EntityManager after application initialization or deployment, before the app tries obtaining them. See https://eclipse.dev/eclipselink/documentation/2.5/jpa/extensions/p_deploy_on_startup.htm for details. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
we have problems with multiple threads creating entity managers the first time a persistence unit is used, the overall picture is that many threads are waiting for more than one minute on EntityManagerFactoryDelegate.getAbstractSession (we have 64 threads running concurrently), an example of one of such 63 threads:
And then the thread which is blocking:
My first question, is such slowness by the creating of an EntityManager expected under some configuration? To my knowledge the database is performing just fine.
I have been looking at how one could improve that, and by looking at the codebase, I would have tried to set in the persistence unit the following properties:
Does it make sense to do so if we are sure we are running on an Oracle 19 database? Are there any drawbacks other that we disable the automatic configuration? I could not find any documentation that list any drawbacks.
Kind Regards
Beta Was this translation helpful? Give feedback.
All reactions