1

I have an application, written in JEE, JPA, I use Payara as the application server.

In my application's persistence.xml I have

<persistence-unit name="XYZ" transaction type="JTA" >

On the payara side, I have JDBC resource called XYZ, with JDBC connection Pool. The database used by the application is dedicated to one customer.

Now I want to deploy this app (unchanged) to other customers (on the same server), each customer needs separate database. In order to achieve that I need to modify persistence unit name for each customer and recompile the app, and of course, define JDBC on the Payara side.

I would like to somehow have this persistence unit name being dynamic, so I don't have to recompile the app for each customer. Is there any simple way to achieve that? In the worst case, I can just modify persistence.xml in the compiled war file, but I hope a more elegant solution exists.

Please advise how to solve that issue.

norbi771
  • 814
  • 2
  • 12
  • 29

1 Answers1

0

You can setup a own Instance inside Payara for every customer and deploy your Program to these Instances.
Then you're able to set a variable, different for each Instance.
This variable can than be used inside your persistence.xml.

Using variables is documentated here:
https://docs.payara.fish/community/docs/documentation/payara-server/server-configuration/var-substitution/README.html

frank
  • 1,007
  • 1
  • 6
  • 13