I have a DBUnit test which runs OK, but is taking ages (4-5 mins) to create the entity manager factory. I am using JPA with hibernate and SQL serve. Would be of great help if anybody could throw some light on this. My machine seems faster to blame it on Sql server :) Here is my setup code.
@BeforeClass
public static void initEntityManager() throws Exception {
emf = Persistence.createEntityManagerFactory("primary");
em = emf.createEntityManager();
tx = em.getTransaction();
connection = new DatabaseConnection(((EntityManagerImpl) em).getSession().connection());
dataset = getDataSet();
}
And here is my Persistence.xml
<persistence-unit name="primary" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.prototype.database.Customer</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.connection.username" value="testuser" />
<property name="hibernate.connection.password" value="testuser" />
<property name="hibernate.connection.url" value="jdbc:sqlserver://localhost:1433;DatabaseName=testdb"/>
</properties>
</persistence-unit>