Re: Set DB Adapter in code

2016-10-18 Thread John Huss
Hmmm, not sure. Another option is to define both nodes in CayenneModeler and remove the one that you don't need at runtime before running any queries or commits. On Tue, Oct 18, 2016 at 12:19 PM Hugi Thordarson wrote: > Thanks John, I had made it just about that far, but how do I obtain an > in

Re: Set DB Adapter in code

2016-10-18 Thread Hugi Thordarson
Thanks John, I had made it just about that far, but how do I obtain an instance of an adapter? Cheers, - hugi > On 18. okt. 2016, at 16:56, John Huss wrote: > > Something like this? > > Collection nodes = runtime.getDataDomain().getDataNodes(); > > for (DataNode node : nodes) { > > node.se

Re: Set DB Adapter in code

2016-10-18 Thread Hugi Thordarson
Yeah, I’m managing to connect to the DB fine, but it’s still using the Custom Adapter set in my data node, I want to override that. Cheers, - hugi > On 18. okt. 2016, at 16:34, Michael Gentry wrote: > > Here is one example of using SimpleJNDI to bind to a local H2 DB for > testing (assuming

Re: Set DB Adapter in code

2016-10-18 Thread John Huss
Something like this? Collection nodes = runtime.getDataDomain().getDataNodes(); for (DataNode node : nodes) { node.setAdapter(myNewAdapter); } On Tue, Oct 18, 2016 at 11:27 AM Hugi Thordarson wrote: > Hi all, > when running tests I need to switch the DB adapter to H2Adapter (my > DataNode ha

Re: Set DB Adapter in code

2016-10-18 Thread Michael Gentry
Here is one example of using SimpleJNDI to bind to a local H2 DB for testing (assuming your normal application uses JNDI): https://github.com/mrg/cbe/blob/master/UnitTesting/src/test/java/cbe/testing/AppTest.java The example is still on Cayenne 3.0.2, but hopefully that'll help. mrg On Tue, Oc

Set DB Adapter in code

2016-10-18 Thread Hugi Thordarson
Hi all, when running tests I need to switch the DB adapter to H2Adapter (my DataNode has a Customer adaptor). How would this be easiest to do? Cheers, - hugi

Re: DB with totally manually managed primary keys

2016-10-18 Thread Hugi Thordarson
Ah, of course everything works like a charm as soon as I’ve provided the value myself. Thanks Michael! Cheers, - hugi > On 18. okt. 2016, at 15:38, Michael Gentry wrote: > > Hi Hugi, > > Take a look at the model/code under here: > > https://github.com/mrg/cbe/tree/master/InsertingObjects/M

Re: DB with totally manually managed primary keys

2016-10-18 Thread Michael Gentry
Hi Hugi, Take a look at the model/code under here: https://github.com/mrg/cbe/tree/master/InsertingObjects/MeaningfulPK Essentially you map the meaningful key as a Java attribute and set the DB PK generation strategy to "Default" for those tables. As long as you supply the meaningful PKs, Cayen

DB with totally manually managed primary keys

2016-10-18 Thread Hugi Thordarson
Hi all, I’m currently working on a legacy DB where primary key values are both meaningful and completely manually managed in code (no automatic PK generation, sequences or anything, but have to be specified by the programmer). How do I tell Cayenne to not attempt to create PKs? Cheers, - hugi