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

北慕城南 提交于 2019-12-10 23:58:13

问题


hi i just want to know how configure in a persistence.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


回答1:


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>


来源:https://stackoverflow.com/questions/3266688/its-possible-configure-a-persistence-xml-for-multiple-data-sources

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!