下面是我从网上找到的关于JPA配置文件persistence.xml的相关描述:
1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <persistence version="1.0" 4 xmlns:persistence="http://java.sun.com/xml/ns/persistence" 5 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 6 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd "> 7 8 <!-- 9 Name属性用于定义持久化单元的名字 (name必选,空值也合法); 10 transaction-type 指定事务类型(可选) 11 --> 12 <persistence-unit name="LMS" transaction-type="JTA"> 13 14 <!-- 描述信息.(可选) --> 15 <description> </description> 16 17 <!-- javax.persistence.PersistenceProvider接口的一个实现类(可选) --> 18 <provider> </provider> 19 20 <!-- Jta-data-source和 non-jta-data-source用于分别指定持久化提供商使用的JTA和/或non-JTA数据源的全局JNDI名称(可选) --> 21 <jta-data-source>java:/LMSNGDataSource_UW</jta-data-source> 22 <non-jta-data-source> </non-jta-data-source> 23 24 <!-- 声明orm.xml所在位置.(可选) --> 25 <mapping-file>product.xml</mapping-file> 26 27 <!-- 以包含persistence.xml的jar文件为基准的相对路径,添加额外的jar文件.(可选) --> 28 <jar-file>../lib/model.jar</jar-file> 29 30 <!-- 显式列出实体类,在Java SE 环境中应该显式列出.(可选) --> 31 <class>com.domain.User</class> 32 <class>com.domain.Product</class> 33 34 <!-- 声明是否扫描jar文件中标注了@Enity类加入到上下文.若不扫描,则如下:(可选) --> 35 <exclude-unlisted-classes>true</exclude-unlisted-classes> 36 <!--可选 --> 37 <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode> 38 <!-- 厂商专有属性(可选) --> 39 <properties> 40 <!-- hibernate.hbm2ddl.auto= create-drop / create / update --> 41 <property name="hibernate.cache.use_second_level_cache" 42 value="true" /> 43 <property name="hibernate.cache.use_query_cache" value="true" /> 44 <property name="hibernate.hbm2ddl.auto" value="update" /> 45 <property name="hibernate.show_sql" value="true" /> 46 </properties> 47 48 </persistence-unit> 49 50 </persistence>
JavaEE学习之JPA中配置文件persistence.xml
原文:http://www.cnblogs.com/pszw/p/3535813.html