【问题标题】:it's possible configure a persistence.xml for multiple data sources?是否可以为多个数据源配置一个 persistence.xml?
【发布时间】:2011-03-17 01:15:17
【问题描述】:

您好,我只想知道如何在persistence.xml 中配置两个数据源,其中一个数据源在另一个外部有一个jar。我试过了,但如果可能的话我真的不这样做

【问题讨论】:

    标签: java jpa jakarta-ee persistence.xml ejb-3.0


    【解决方案1】:

    是的,您可以在 persistence.xml 中配置两个数据源。您只需要两个单独的元素。

    <persistence>
       <persistence-unit name="datasourceOne">
           <jta-data-source>java:/DefaultDS</jta-data-source>
           <jar-file>../MyApp.jar</jar-file>
           <class>org.acme.Employee</class>
           <class>org.acme.Person</class>
           <class>org.acme.Address</class>
           <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
                <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
           </properties>
       </persistence-unit>
    
       <persistence-unit name="datasourceTwo">
         <!-- some configuration -->
      </persistence-unit>
    </persistence>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-30
      • 2018-05-13
      • 2017-02-28
      • 1970-01-01
      • 2021-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多