Quote:
Is there a way to speed up? or initialize lazily?
Lazy initialization is not provided by Hibernate.
I past I got a problem (only on Windows OS) where buildEntityManagerFactory stuck most time in scanning for
annotated classes in my jar-file. Since then I deploy the entity classes into a separate jar-file and refer it in my persistence.xml as follows:
Code:
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit>
<jar-file>persistentclasses.jar</jar-file>
...
This did speed up buildEntityManagerFactory.
N.B.: in my case I let Hiberante scan automatically for annotated entity classes.