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

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.
主站蜘蛛池模板: 安康市| 深水埗区| 怀仁县| 永福县| 新宁县| 凤台县| 英山县| 建昌县| 阿荣旗| 蒙山县| 辽宁省| 怀远县| 鹤岗市| 从江县| 西充县| 安新县| 尼玛县| 辽阳县| 台南县| 罗平县| 舞阳县| 扎鲁特旗| 南汇区| 武功县| 玉田县| 汝南县| 津南区| 会东县| 龙门县| 台安县| 辽中县| 灵璧县| 洪泽县| 尉氏县| 托里县| 汉沽区| 廊坊市| 饶河县| 兴业县| 田东县| 鹤庆县|