JPA持久化配置
2017-08-03 本文已影响0人
__Jingyu__
- 1.首先需要配置服务器glassfish的数据库连接池,又叫资源连接池:
- 2.然后配置persistence unit:
-
整个Persistence unit的格式如下:
-配置实例:
-
<persistence version="2.1" xmlns="http://xmlns.jcp.org/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_1.xsd">
<persistence-unit name="RealEstateAgencyPU" transaction-type="JTA">
<jta-data-source>jdbc/RealEstateDataSource</jta-data-source>
<class>fit5042.tutex.repository.entities.ContactPerson</class>
<class>fit5042.tutex.repository.entities.Property</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
-
其中:
就是这条: