There's a bug that we've seen with this, just haven't got to the bottom of it yet.
All I know is that overriding the strategy does not if another strategy is already present in the XML and sometimes (always?) the Modeler sticks the default strategy in there. As I am currently in favor of DataNode-less projects, I don't ever see it myself, but it was reported a few times by others. Need to open a Jira I guess and create a fix. Andrus > On Jan 23, 2016, at 5:47 PM, Michael Gentry <mgen...@masslight.net> wrote: > > Hi Hugi, > > This worked for me in 3.1: > > // Use a custom Cayenne server runtime. > serverRuntime = new ServerRuntime("my cayenne model", new > CayenneExtrasModule())); > > ... > > /** > * Custom Cayenne DI module. > */ > private static class CayenneExtrasModule implements Module > { > @Override > public void configure(Binder binder) > { > // Change the SchemaUpdateStrategy to create the DB schema for > unit > // testing instead of using the model's default which assumes an > // existing schema. > > binder.bind(SchemaUpdateStrategy.class).to(CreateIfNoSchemaStrategy.class); > } > } > > > On Sat, Jan 23, 2016 at 7:33 AM, Hugi Thordarson <h...@karlmenn.is> wrote: > >> Hi Michael, Andrus and Savva. >> >> Thanks a lot for all the help with this :). The arguments to the >> ServerRuntimeBuilder are exactly what I wanted :). >> >> One thing though: Setting the SchemaUpdateStrategy in code (in the >> ServerRuntimeBuilder) doesn’t work for me. Works great if I set it in the >> cayenne modeler, but if the modeler has the default >> “SkipSchemaUpdateStrategy” selected, changing it in the >> ServerRuntimeBuilder doesn’t seem to do anything. Any ideas? >> >> This is how I’m currently initializing my server runtime >> >> public static ServerRuntime serverRuntime() { >> if (_serverRuntime == null) { >> _serverRuntime = new ServerRuntimeBuilder() >> .addConfig("cayenne-project.xml") >> .addModule(binder -> >> binder.bind(SchemaUpdateStrategy.class).to(CreateIfNoSchemaStrategy.class)) >> .jdbcDriver("org.h2.Driver") >> .url("jdbc:h2:~/h2-testing") >> .build(); >> } >> >> return _serverRuntime; >> } >> >> Cheers, >> - hugi