好了,下面来看映射文件的写法
<?xml version="1.0" encoding="UTF-8"?>
<!--
1.该xml文件可以包含多个persistent元素,每个元素都可以定义自己的持久层实现类和数据库 2.实体类在<class>标签中声明
-->
<persistence 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_1_0.xsd"
version="1.0">
<persistence-unit name="testjpa" transaction-type="RESOURCE_LOCAL">
<!-- 使用OpenJPA持久层实现 -->
<!--
Provider class that supplies EntityManagers for this persistence unit
-->
<provider>
org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
<!-- 映射实体类 -->
<class>com.liliang.entity.Customer</class>
<!-- A list of vendor-specific properties. -->
<properties>
<property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/hibernate" />
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver" />
<property name="openjpa.ConnectionUserName" value="root" />
<property name="openjpa.ConnectionPassword" value="1d280478" />
<property name="openjpa.Log" value="SQL=TRANCE" />
</properties>
</persistence-unit>
</persistence>