JPA持久化配置

  • 1.首先需要配置服務(wù)器glassfish的數(shù)據(jù)庫連接池,又叫資源連接池:
  • 2.然后配置persistence unit:
    • 整個(gè)Persistence unit的格式如下:



      -配置實(shí)例:

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



    就是這條:


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容