0

I created one spring boot application. When I run this I am getting below error for persiatance.xml.

Seems like it is not reading my persistance.xml file. Could you please help me in resolving the issue.

Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named EmployeeData
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:61)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    at com.JPAproject.Entity.InsertEmployee.main(InsertEmployee.java:11)

Below are the related file for reference:

Entity class

package com.JPAproject.Entity;

import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="Employee_JPA")
public class Employee_EntityManager {

    private String e_id;
    private String e_name;
    private Integer e_age;

    public String getE_id() {
        return e_id;
    }
    public void setE_id(String e_id) {
        this.e_id = e_id;
    }
    public String getE_name() {
        return e_name;
    }
    public void setE_name(String e_name) {
        this.e_name = e_name;
    }
    public Integer getE_age() {
        return e_age;
    }
    public void setE_age(Integer e_age) {
        this.e_age = e_age;
    }
    public Employee_EntityManager(String e_id, String e_name, Integer e_age) {
        super();
        this.e_id = e_id;
        this.e_name = e_name;
        this.e_age = e_age;
    }
    public Employee_EntityManager() {
        super();
    }



}

Persistance.xml

<?xml version="1.0" encoding="UTF-8"?>

<persistence version="2.1" 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_1.xsd">
<persistence-unit name="EmployeeData" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.JPAproject.Employee_EntityManager</class>
</persistence-unit>    
</persistence>
G.Chahar
  • 185
  • 6
  • 19

1 Answers1

0

The org.hibernate.ejb.HibernatePersistence class has been deprecated for a long time, but you still find it in old tutorials. You need to use the new one org.hibernate.jpa.HibernatePersistenceProvider.

You also don't seem to have a data source, if that is your full XML file, and not a reduced version, so that you don't post passwords and such.

coladict
  • 4,799
  • 1
  • 16
  • 27