嘿,我正在学习这些东西,我真的不了解所有这些,我有一个问题,我不知道在persistence.xml中的提供者标签写什么
以下是我的persistence.xml和pom.xml文件:
的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test.jpa</groupId>
<artifactId>JPAProject</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.36</version>
</dependency>
</dependencies>
<build>
<finalName>JPAProject</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</build>
的persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_0.xsd">
<persistence-unit name="Database" transaction-type="RESOURCE_LOCAL">
<class>models.Employee</class>
<provider>WHAT TO WRITE HERE ?</provider>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/jpa"/>
<property name="javax.persistence.jdbc.user" value="root"/>
<property name="javax.persistence.jdbc.password" value="root"/>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
</properties>
</persistence-unit>
答案 0 :(得分:4)
在provider
代码中,您需要包含特定于供应商的PersistenceProvider
实施。
请参考EXPLAIN ANALYZE
;你可能会对此有所了解。
回答你的问题: -
如果您想使用JPA的Eclipselink实施,请使用下面的provider
标记 -
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
OR
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
用于JPA的Hibernet实现。