官术网_书友最值得收藏!

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.
主站蜘蛛池模板: 疏勒县| 海淀区| 合阳县| 新昌县| 塔河县| 张北县| 湘潭县| 和林格尔县| 临海市| 清镇市| 台中市| 淳化县| 扎兰屯市| 诸暨市| 南陵县| 泾源县| 延边| 乌兰县| 洛宁县| 阳信县| 龙里县| 南阳市| 赤水市| 望奎县| 观塘区| 休宁县| 霸州市| 买车| 柳州市| 长兴县| 兰西县| 北流市| 宜昌市| 泰顺县| 三江| 定州市| 琼海市| 长垣县| 竹北市| 根河市| 阳曲县|