JPA持久化配置

  • 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>
  • 其中:



    就是这条:


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容