- Developing Middleware in Java EE 8
- Abdalla Mahmoud
- 98字
- 2021-07-23 19:24:36
Step 2: Creating a persistence unit
A persistence unit in is named scope where we define persistence contextual details such as data source information, a list of entities to include (or exclude), and any other information that may be useful for the persistence provider to work. A persistence unit is identified by a unit name, and is created by defining the following file:
/META-INF/persistence.xml <?xml version="1.0" encoding="UTF-8"?> <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="jpa-examplesPU" transaction-type="JTA"> <jta-data-source>java:app/cinemasapp-ds</jta-data-source> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="javax.persistence.schema-generation.database.action" value="create"/> </properties>
</persistence-unit> </persistence>
Note that by setting the exclude-unlisted-classes property to false, all entity classes found by the persistence provider inside the WAR deployment file will be included in the context of the persistence unit.
推薦閱讀
- UI圖標創意設計
- 測試驅動開發:入門、實戰與進階
- Oracle從新手到高手
- Python自動化運維快速入門(第2版)
- vSphere High Performance Cookbook
- Python測試開發入門與實踐
- 神經網絡編程實戰:Java語言實現(原書第2版)
- Learn Programming in Python with Cody Jackson
- 高級C/C++編譯技術(典藏版)
- 零基礎學Python網絡爬蟲案例實戰全流程詳解(入門與提高篇)
- Building Microservices with .NET Core
- Kubernetes進階實戰
- Spring 5 Design Patterns
- Groovy 2 Cookbook
- 嵌入式C編程實戰