Re: Testing & Map
Thanks! > On Jul 9, 2019, at 7:43 PM, Tony wrote: > > 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 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 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 wrote: I am trying to genericize the map.xml for multiple instances with multiple dbnames (looking for a “use ” 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_” (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: … 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 ” 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 >>
Re: Testing & Map
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 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 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 wrote: >>> >>> I am trying to genericize the map.xml for multiple instances with multiple >>> dbnames (looking for a “use ” 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_” (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: >>> >>> >>> … >>> >>> >>> 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 ” 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 >>> >
Re: Testing & Map
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 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 wrote: >> >> I am trying to genericize the map.xml for multiple instances with multiple >> dbnames (looking for a “use ” 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_” (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: >> >> >> … >> >> >> 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 ” 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 >>
Re: Testing & Map
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 wrote: > > I am trying to genericize the map.xml for multiple instances with multiple > dbnames (looking for a “use ” 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_” (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: > > >… > > > 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 ” 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 >
Re: Testing & Map
re genericize-strategy > 2. or could I do something with db-entity tag so that it would ref the > defaultSchema? I did some hacking with the cayenne-modeler-generated map.xml config file. Unexpectedly, all of my map.xml hacks worked as expected (see below. As best as I can tell (from “blackbox” testing - using cayenne log files to verify), removing the [schema=“dbname”] ref results in cayenne-runtime generating SQL-FROM with an unqualified table-name (i.e. appropriate behavior). Then when I went further, and deleted the default schema tag, runtime still created an unqualified FROM (i.e. appropriate behavior). It Appears: If the schema-refs and default-schema tags are removed from map.xml, then cayenne-runtime relies upon the connection-url as the dbname - namespace. This appears to be standard behavior written into cayenne. Question: 1. is there any down-side to configuring the project absent the schema-refs (as described in these hacks)? 2. note: cayenne-runtime seems to respond with the appropriate behavior, so my guess is that someone designed it this way TESTS (all 4x tests passed) Cayenne v4.0.1 — original: (cayenne map.xml config with no mods) ——— map.xml: cayenne runtime sql: … from database1.table1 hack1: (blank schema ref) ——— map.xml: ... cayenne runtime sql: … from table1 hack2: (schema ref deleted) ——— map.xml: ... cayenne runtime sql: … from table1 hack3: (schema ref & defaultSchema tag deleted) ——— map.xml: cayenne runtime sql: … from table1 Joe > On Jul 7, 2019, at 11:18 AM, Joe Baldwin wrote: > > John, > >> https://stackoverflow.com/questions/18948418/set-database-path-in-cayenne > > > Thanks for the link. I perused Andrus’ post, as well as the embedded link. > I am not quite following your suggested strategy though … > > 1. As best as I can tell, the posting suggests a strategy that addresses the > connection-url (not the multiple schema-refs in the cayenne-generated map.xml > file) > > 2. Core Issue: > - if I did not define the problem well enough, here is an example ... > - (from log-file analysis), cayenne-runtime generates select statements > with fully qualified table names > - ex: "d1.t1” > - it appears to get “d1” from the cayenne-modeler generated map.xml > file schema-ref > ex: "” > - there are currently about 25-30 references in the cayenne > config files > - changing the connection-url alone does *not* change the dbname in the > runtime-select-statements (per log file) > - if I just change the connection-url to another dbname, > cayenne still uses the map.xml schema references to qualify the table names > - so even if you specify “d0” in your connection url, cayenne > will override and generate sql based on the scheme-ref “d1" in the map.xml > file > - therefore, in order to support multiple instances of my app (each > with a separate dbname), I am forced to change all 25-30 schema-refs for > every instance I support. > > 3. My goal: > - genericize the 25-30x schema-refs to 1x schema-ref, so that I can > deploy to multiple instances (each with its own dbname). > - I am hoping for a DBMS-like namespace specifier (like “use dbname”) > to change the schema-ref in one location. > > > Comments: > 1. my current strategy manual strategy is working - it is just “klunky”, and > does not easily support CI/CD. > 2. Just trying to find out if the (schema-namespace / single-change) strategy > is possible - if not, I will just go with the manual strategy > > To Simplify: > 1. Is there a way to specify the dbname in *one* location (like a single > config file, or gradle param)? > 2. or could I do something with db-entity tag so that it would ref the > defaultSchema? > > so instead of > > it might say: > > > > Thanks, > Joe > > > > >> On Jul 6, 2019, at 10:04 PM, John Huss wrote: >> >> https://stackoverflow.com/questions/18948418/set-database-path-in-cayenne >> >> On Sat, Jul 6, 2019 at 8:36 PM Joe Baldwin wrote: >> >>> I am trying to genericize the map.xml for multiple instances with multiple >>> dbnames (looking for a “use ” 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_” (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)
Re: Testing & Map
John, > https://stackoverflow.com/questions/18948418/set-database-path-in-cayenne Thanks for the link. I perused Andrus’ post, as well as the embedded link. I am not quite following your suggested strategy though … 1. As best as I can tell, the posting suggests a strategy that addresses the connection-url (not the multiple schema-refs in the cayenne-generated map.xml file) 2. Core Issue: - if I did not define the problem well enough, here is an example ... - (from log-file analysis), cayenne-runtime generates select statements with fully qualified table names - ex: "d1.t1” - it appears to get “d1” from the cayenne-modeler generated map.xml file schema-ref ex: "” - there are currently about 25-30 references in the cayenne config files - changing the connection-url alone does *not* change the dbname in the runtime-select-statements (per log file) - if I just change the connection-url to another dbname, cayenne still uses the map.xml schema references to qualify the table names - so even if you specify “d0” in your connection url, cayenne will override and generate sql based on the scheme-ref “d1" in the map.xml file - therefore, in order to support multiple instances of my app (each with a separate dbname), I am forced to change all 25-30 schema-refs for every instance I support. 3. My goal: - genericize the 25-30x schema-refs to 1x schema-ref, so that I can deploy to multiple instances (each with its own dbname). - I am hoping for a DBMS-like namespace specifier (like “use dbname”) to change the schema-ref in one location. Comments: 1. my current strategy manual strategy is working - it is just “klunky”, and does not easily support CI/CD. 2. Just trying to find out if the (schema-namespace / single-change) strategy is possible - if not, I will just go with the manual strategy To Simplify: 1. Is there a way to specify the dbname in *one* location (like a single config file, or gradle param)? 2. or could I do something with db-entity tag so that it would ref the defaultSchema? so instead of it might say: Thanks, Joe > On Jul 6, 2019, at 10:04 PM, John Huss wrote: > > https://stackoverflow.com/questions/18948418/set-database-path-in-cayenne > > On Sat, Jul 6, 2019 at 8:36 PM Joe Baldwin wrote: > >> I am trying to genericize the map.xml for multiple instances with multiple >> dbnames (looking for a “use ” 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_” (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: >> >> >>… >> >> >> 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 ” 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 >> >>
Re: Testing & Map
https://stackoverflow.com/questions/18948418/set-database-path-in-cayenne On Sat, Jul 6, 2019 at 8:36 PM Joe Baldwin wrote: > I am trying to genericize the map.xml for multiple instances with multiple > dbnames (looking for a “use ” 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_” (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: > > > … > > > 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 ” 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 > >