I am trying to genericize the map.xml for multiple instances with multiple
dbnames (looking for a “use <dbname>” analogue for cayenne config files - or a
better idea if you have one)
Details ...
Context:
cayenne: 4.0.1
db: mysql 8.0.16
dbname: “cms" / “cmstest" / "cms_<bunch of others suffixes>” (all referring
to the same schema)
Goals:
- migrate to cicd (gradle, git, jenkins, automated testing,etc)
- support testing configurations, as well as multiple instances of the same
app but with unique dbnames
Prob:
While trying to migrate to fully automated testing (using junit-5) I hit a snag:
- the cayenne map.xml has the datasource name (“cms” in this instance)
embedded in the map.xml config file:
<property name="defaultSchema" value="cms”/>
...
<db-entity name="admin" schema="cms">
…
</db-entity>
So the general idea I had was to create a tmp-test database (cmstest), run the
junit tests for unit & complex unit testing configured using gradle, then move
on to a more complex testing config downstream. When I deploy it will be to
multiple instances (with unique dbnames).
But I cannot figure out how to genericize this map.xml so that I can easily
change the datasource name - I could throw sed/awk at it - to change all the
schema-name-refs, but I was hoping for something a bit more cayenne-oriented
(and less brittle than sed/awk).
Ideally, I am searching for a cayenne-analogue to mysql “use <dbname>” so that
I could change the datasource name in one location (vs 25).
Thanks
Joe
PS if you have any other gradle tricks that you rely on, please do send a link