Persistence.xml 配置说明

前端之家收集整理的这篇文章主要介绍了Persistence.xml 配置说明前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Persistence.xml 配置说明
2011-10-09 20:27:31
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处、作者信息和本声明。否则将追究法律责任。 http://www.jb51.cc/article/p-hbcugsfa-bau.html
本文转载于:http://www.cnblogs.com/jdonson/archive/2009/07/24/1530356.html
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns:persistence="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd ">
<!--
Name属性用于定义持久化单元的名字 (name必选,空值也合法);
transaction-type 指定事务类型(可选)
-->
<persistence-unit name="unitName" transaction-type="JTA">
<!-- 描述信息.(可选) -->
<description> </description>
<!-- javax.persistence.PersistenceProvider接口的一个实现类(可选) -->
<provider> </provider>
<!-- Jta-data-source和 non-jta-data-source用于分别指定持久化提供商使用的JTA和/或non-JTA数据源的全局JNDI名称(可选) -->
<jta-data-source>java:/MysqLDS</jta-data-source>
<non-jta-data-source> </non-jta-data-source>
<!-- 声明orm.xml所在位置.(可选) -->
<mapping-file>product.xml</mapping-file>
<!-- 以包含persistence.xml的jar文件为基准的相对路径,添加额外的jar文件.(可选) -->
<jar-file>../lib/model.jar</jar-file>
<!-- 显式列出实体类,在Java SE 环境中应该显式列出.(可选) -->
<class>com.domain.User</class>
<class>com.domain.Product</class>
<!-- 声明是否扫描jar文件中标注了@Enity类加入到上下文.若不扫描,则如下:(可选) -->
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<!-- 厂商专有属性(可选) -->
<properties>
<!-- hibernate.hbm2ddl.auto= create-drop / create / update -->
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<!--
persistence-unit name="EjbXmlMappingsPU" // 持久化单元名
transaction-type="JTA(default)/RESOURCE_LOCAL" // 事务类型
-->
<persistence-unit name="EjbXmlMappingsPU" transaction-type="JTA">
<description></description> <!-- 描述 -->
<provider>oracle.toplink.essentials.PersistenceProvider</provider> <!-- 指定一个持久化提供者 -->
<jta-data-source>jdbc/MyDataSource</jta-data-source> <!-- 指定JTA数据源 -->
<non-jta-data-source>jdbc/NonTxMyDataSource</non-jta-data-source> <!-- 指定非JTA数据源 -->
<mapping-file>Meta-INF/my_queries.xml</mapping-file> <!-- 指定映射文件 -->
<mapping-file>Meta-INF/my_entities.xml</mapping-file>
<jar-file>my/my-classes.jar</jar-file> <!-- 指定托管类的附加JAR -->
<class>myclass1</class> <!-- 明确列出的类 -->
<class>myclass2</class>
<exclude-unlisted-classes/> <!-- 使本地类不能被加到持久化单元中 -->
<properties> <!-- 使用提供者属性 -->
<property name="toplink.logging.level" value="FINE"/>
<property name="toplink.cache.size.dafault" value="500"/>
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistencehttp://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="itcast" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MysqL5Dialect"/>
<property name="hibernate.connection.driver_class" value="org.gjt.mm.MysqL.Driver"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="root"/>
<property name="hibernate.connection.url" value="jdbc:MysqL://localhost:3306/itcast_shoping?useUnicode=true&amp;characterEncoding=UTF-8"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.jdbc.fetch_size" value="18"/>
<property name="hibernate.jdbc.batch_size" value="10"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="false"/>
</properties>
</persistence-unit>
</persistence>
原文链接:https://www.f2er.com/xml/296373.html

猜你在找的XML相关文章