Simply put, persistence provider refers to the specific JPA implementation used in our application to persist objects to the database. To learn more about JPA and its implementations, we can refer to our article on the difference between JPA, Hibernate, and EclipseLink.
You need to move persistence. xml to a location on your app server's class path. For a Maven project, that is typically in the src/main/resources folder. Check the Hibernate documentation to see if Hibernate expects the file to be in a sub-folder, or if putting it in the root of the classpath is OK.
Spring Boot will not search for or use a META-INF/persistence. xml by default. If you prefer to use a traditional persistence. xml , you need to define your own @Bean of type LocalEntityManagerFactoryBean (with an ID of 'entityManagerFactory') and set the persistence unit name there.
The persistence. xml file is a standard configuration file in JPA. It has to be included in the META-INF directory inside the JAR file that contains the entity beans. The persistence. xml file must define a persistence-unit with a unique name in the current scoped classloader.
Put the "hibernate-entitymanager.jar"
in the classpath of application.
For newer versions, you should use "hibernate-core.jar"
instead of the deprecated hibernate-entitymanager
If you are running through some IDE, like Eclipse: Project Properties -> Java Build Path -> Libraries.
Otherwise put it in the /lib
of your application.
After <persistence-unit name="agisdb">
, define the persistence provider name:
<provider>org.hibernate.ejb.HibernatePersistence</provider>
Make sure that the persistence.xml
file is in the directory: <webroot>/WEB-INF/classes/META-INF
Faced the same issue and couldn't find solution for quite a long time. In my case it helped to replace
<provider>org.hibernate.ejb.HibernatePersistence</provider>
with
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
Took solution from here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With