0

I want to use a Apache Cayenne Java Web Application in a Docker container, as there are multiple instances running I would like to customize them by environment variables. Now I have the problem that I'm using one central database, with different catalogs for each instance/container. Is there a possibility to set the defaultCatalog (which is defined in the xxx.map.xml) by an env. variable?

regards Markus

Meex
  • 45
  • 3

1 Answers1

0

The "default" catalog in Cayenne only controls what catalog is assigned to newly created DbEntities in the Modeler and has no effect on runtime behavior.

Now, in runtime on most databases the default catalog is controlled via the connection URL (i.e. at JDBC level outside Cayenne). E.g.

jdbc:mysql://127.0.0.1/database
jdbc:postgresql://127.0.0.1/database

In both MySQL and Postgres examples "database" is the db name (which is the same as catalog).

So what you need to do is to keep the catalog empty for all Cayenne DbEntities (not just the "default" catalog of the DataMap), and then specify connection URL for each Docker container with an appropriate DB name. One way to control this is via -Dcayenne.jdbc.url startup property.

andrus_a
  • 2,528
  • 1
  • 16
  • 10