image.png
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<!--需要配置persistence-unit節(jié)點
持久化單元
name:持久化單元名稱
transaction-type:事務(wù)管理方式
JTA:分布式事務(wù)管理
RESOURCE_LOCAL:本地事務(wù)管理
-->
<!-- <persistence-unit name="myJpa" transaction-type="JTA"></persistence-unit>-->
<persistence-unit name="myJpa" transaction-type="RESOURCE_LOCAL">
<!-- jpa的實現(xiàn)方式-->
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<!-- 可選的配置授账,配置jpa實現(xiàn)方的配置信息-->
<properties>
<!-- 數(shù)據(jù)庫信息
用戶名:javax.persistence.jdbc.user
密碼:javax.persistence.jdbc.password
驅(qū)動:javax.persistence.jdbc.driver
數(shù)據(jù)庫地址:javax.persistence.jdbc.url
-->
<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"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql:///jpa?characterEncoding=utf-8"/>
<!-- 配置jpa實現(xiàn)方(hibernate)的配置信息
顯示sql false|true
自動創(chuàng)建數(shù)據(jù)庫 hibernate.hbm2ddl.auto
creat :程序運行時創(chuàng)建數(shù)據(jù)庫表(如果有表吗购,先刪除再創(chuàng)建)
update :程序運行時創(chuàng)建表(如果有表疤剑,不會創(chuàng)建表)
none :不會創(chuàng)建表
-->
<property name="hibernate.show_sql" value="true"/>
<!-- <property name="hibernate.hbm2ddl.auto" value="create"/>-->
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>