开发者

it's possible configure a persistence.xml for multiple data sources?

开发者 https://www.devze.com 2023-01-07 06:25 出处:网络
hi i just want to know how configure in a per开发者_Python百科sistence.xml two datasources one of the data sources have a jar outside from the other. I\'m tried but i really don\'t if it\'s possibleYe

hi i just want to know how configure in a per开发者_Python百科sistence.xml two datasources one of the data sources have a jar outside from the other. I'm tried but i really don't if it's possible


Yeah, you can have two datasources configured in a persistence.xml. You would just need two separate elements.

<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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号