Я пытаюсь настроить простой проект JPA с EclipseLink и Payara.
Я создал источник данных в Payara и мог успешно пропинговать его. Но, пытаясь сохранить свою сущность, я получаю:
Object: Employee(eid=1201, ename=Gopal, salary=40000.0, deg=Technical Manager) is not a known Entity type.
Приложение:
@PersistenceContext(unitName = "my_persistence_unit")
protected EntityManager em;
public void func() {
Employee employee = new Employee();
employee.setEid(1201);
employee.setEname("Gopal");
employee.setSalary(40000);
employee.setDeg("Technical Manager");
em.persist(employee);
em.flush();
em.close();
}
Сотрудник:
@Entity
@Data
public class Employee implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long eid;
private String ename;
private double salary;
private String deg;
}
постоянство. xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.2" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
<persistence-unit name="my_persistence_unit" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
<jta-data-source>jdbc/myRes</jta-data-source>
</persistence-unit>
</persistence>
POM:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.7.6</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
</dependency>
Почему Employee
не является известным объектом, хотя я аннотировал его как @Entity
?