Joe, 

Delete the schema name in the modeler. Just leave it empty at the highest level 
and propagate it down. There’s a button to the left of the text field.

That will remove the schema entry from the model which will remove it from the 
XML. Then at runtime the URL provides the schema. Easy Peasy...

Tony Giaccone

> On Jul 8, 2019, at 3:06 PM, Joe Baldwin <[email protected]> wrote:
> 
> Tony,
> 
>> In our models we never specify the schema
> 
> 
> This sounds like what I was experimenting with.  (Except in my case I thought 
> it was “hacking” - I feel much better now :) )   I just manually edited the 
> map.xml file and deleted the schema - cayenne-runtime seems fine with using 
> the connection-url to define the db namespace.
> 
> Did you set this in the CayenneModeler or via manual editing of the config 
> files?
> 
> Thanks
> Joe
> 
> 
> 
>> On Jul 8, 2019, at 9:23 AM, Tony <[email protected]> wrote:
>> 
>> Joe,
>> 
>> We use cayenne with both drone and Jenkins. In our models we never specify 
>> the schema. It’s always left unspecified I.e. blank.
>> 
>> When you do this the schema is determined by the JDBC URL. In our world the 
>> schemas are always the same so technically we could specify them but I 
>> personally feel the flexibility of determining database instance and schema 
>> from the environment is far superior to coding either in the model.
>> 
>> We set shell variables to the JDBC url and then pick them up form the 
>> environment. 
>> 
>> This works flawlessly for us.
>> 
>> 
>> 
>> Tony Giaccone
>> 
>>> On Jul 6, 2019, at 9:36 PM, Joe Baldwin <[email protected]> wrote:
>>> 
>>> 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
>>> 
> 

Reply via email to