Reputation: 101
I need to recreate the EntityManagerFactory between tests to ensure my sequences are reset in the JPA sequence generators to match the database.
I either need to recreate the EMF, or reconnect to the datasource based on the current settings.
Although spring-boot runs with an EMF named 'default', creating this again from
Persistence.createEntityManagerFactory("default");
fails with
javax.persistence.PersistenceException: No Persistence provider for EntityManager named default
even though that's the one created my Spring boot.
Is there a simple thing I am missing here?
Upvotes: 0
Views: 258
Reputation: 617
Try adding this to your pom.xml:
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.3.Final</version>
</dependency>
Upvotes: 1