<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns:persistence="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 persistence_1_0.xsd ">
<!-- Name属性用于定义持久化单元的名字 (name必选,空值也合法); transaction-type:JTA和RESOURCE_LOCAL
指定事务类型(可选) -->
<!-- JPA的hibernate实现 -->
<persistence-unit name="jpa_hibernate"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="123" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/youbuysdb" />
<property name="hibernate.show_sql" value="true" />
<!-- hibernate.hbm2ddl.auto属性,当值为create时,每次启动应用就会删除旧表结构,重新创建最新的表结构,数据会丢失; -->
<!-- 当值为update时,每次启动应用,如果实体类有变化的话,就会在原来表结构的基础上新建,原始数据不会丢失; -->
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
<persistence version="1.0"
xmlns:persistence="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 persistence_1_0.xsd ">
<!-- Name属性用于定义持久化单元的名字 (name必选,空值也合法); transaction-type:JTA和RESOURCE_LOCAL
指定事务类型(可选) -->
<!-- JPA的hibernate实现 -->
<persistence-unit name="jpa_hibernate"
transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="123" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/youbuysdb" />
<property name="hibernate.show_sql" value="true" />
<!-- hibernate.hbm2ddl.auto属性,当值为create时,每次启动应用就会删除旧表结构,重新创建最新的表结构,数据会丢失; -->
<!-- 当值为update时,每次启动应用,如果实体类有变化的话,就会在原来表结构的基础上新建,原始数据不会丢失; -->
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>