0

hy guys, i use eclipselink. in past i had always ONE domainname per PU for my url-tag, like this pu:

<persistence>
<persistence-unit name="PU_NAME">
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@DbDomainName:4242:XYZ"/>
</properties>
</persistence-unit>
</persistence>

now i need a PU which has not ONE domainname as url but MORE THAN ONE fixed ip-adr and my app has to choose by itself a reachable ip:

<persistence>
<persistence-unit name="PU_NAME">
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@127.0.0.1:4242:ABC"/>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@127.0.1.0:4242:ABC"/>
</properties>
</persistence-unit>
</persistence>

i have to use one persistence.xml which contains a pool of different persistence-units inside it. like this:

<persistence>
<persistence-unit name="PU_NAME">
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@127.0.0.1:4242:ABC"/>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@127.0.1.0:4242:ABC"/>
</properties>

<persistence-unit name="PU_NAME2">
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:@DbDomainName:4242:XYZ"/>
</properties>
</persistence>

or is there another way to do this?

mr-blubb
  • 11
  • 6
  • To what purpose? EclipseLink an let you pick the datasource to use internally, but you must setup the pools using native api. It is more portable to have different persistence units, 1 per datasource, and have your app pick. If it is for failover, you want this handled by the datasource/driver itself – Chris Oct 19 '15 at 15:50
  • hy christ, thank you for your post!is there a way to automatically load another persistence-unit if the first does not work? – mr-blubb Oct 20 '15 at 12:37

0 Answers0