In my desktop application new databases get opened quite often. I use Hibernate/JPA as an ORM. The problem is, creating the EntityManagerFactory is quite slow, taking about 5-6 Seconds on a fast machine. I know that the
EntityManagerFactory is supposed to be heavyweight but this is just too slow for a desktop application where the user expects the new database to be opened quickly.
- 1. Can I turn off some EntityManagerFactory features to get an instance faster? Or is it possible to create some of the EntityManagerFactory lazily to speed up cration?
- 2. Can I somehow create the EntityManagerFactory object before knowing the database url? I would be happy to turn off all validation for this to be possible.
- 3. By doing so, can I pool EntityManagerFactorys for later use?
- 4. Any other idea how to create the EntityManagerFactory faster?
Any ideas?
Best,
Markus
PS: I have also created a stackoverflow.com question with a +100 bounty:
[1]: http://stackoverflow.com/questions/15036233/hibernate-faster-entitymanagerfactory-creation