我需要persistence.xml中的元素?

我需要persistence.xml中的元素?,第1张

我需要 persistence.xml中的元素

jar-file
您可以使用persistence.xml 。从Java EE
5教程中

<persistence>    <persistence-unit name="OrderManagement">        <description>This unit manages orders and customers. It does not rely on any vendor-specific features and can therefore be deployed to any persistence provider.        </description>        <jta-data-source>jdbc/MyOrderDB</jta-data-source>        <jar-file>MyOrderApp.jar</jar-file>        <class>com.widgets.Order</class>        <class>com.widgets.Customer</class>    </persistence-unit></persistence>

该文件定义了一个名为的持久性单元

OrderManagement
,它使用JTA感知数据源
jdbc/MyOrderDB
。所述
jar-file
class
元素指定管持久类:实体类,可嵌入类和超类映射。该
jar-file
元素指定JAR文件都包含持久化类管理的打包持久单元可见,而该
class
元素明确命名持久化类管理。

对于Hibernate,请看第二章。也可以进行设置和配置以获取更多详细信息。

编辑: 实际上,如果您不介意不符合规范,则Hibernate即使在Java
SE中也支持自动检测。为此,添加

hibernate.archive.autodetection
属性:

<persistence-unit name="eventractor" transaction-type="RESOURCE_LOCAL">  <!-- This is required to be spec compliant, Hibernate however supports       auto-detection even in JSE.  <class>pl.michalmech.eventractor.domain.User</class>  <class>pl.michalmech.eventractor.domain.Address</class>  <class>pl.michalmech.eventractor.domain.City</class>  <class>pl.michalmech.eventractor.domain.Country</class>   -->  <properties>    <!-- Scan for annotated classes and Hibernate mapping XML files -->    <property name="hibernate.archive.autodetection" value="class, hbm"/>    <property name="hibernate.hbm2ddl.auto" value="validate" />    <property name="hibernate.show_sql" value="true" />  </properties></persistence-unit>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5019625.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存