Hi all,

Made some research, and here is what I've found.

Cayenne do switch to System properties (defined via -D or with DI
binding) automatically but it do so only when all properties are
defined.

So this code will work as expected, and use overridden DataSource properties:

ServerRuntime cayenneRuntime =
ServerRuntime.builder().addConfig("cayenne-project.xml")
        .addModule(binder -> ServerModule.contributeProperties(binder)
                .put(Constants.JDBC_DRIVER_PROPERTY, "com.mysql.jdbc.Driver")
                .put(Constants.JDBC_URL_PROPERTY,
"jdbc:mysql://localhost:3306/test")
                .put(Constants.JDBC_USERNAME_PROPERTY, "user")
                .put(Constants.JDBC_PASSWORD_PROPERTY, "password"))
        .build();

While this will ignore password and use DataSource properties from XML:

ServerRuntime cayenneRuntime =
ServerRuntime.builder().addConfig("cayenne-project.xml")
        .addModule(binder -> ServerModule.contributeProperties(binder)
                .put(Constants.JDBC_PASSWORD_PROPERTY, "password"))
        .build();

I will add some information to logs, so at least it wouldn't be
surprising as it is now.
But maybe we should change this to enable override of separate properties.

On Thu, Jan 18, 2018 at 8:27 AM, Andrus Adamchik <and...@objectstyle.org> wrote:
>
>
>> On Jan 17, 2018, at 11:05 PM, Pascal Robert <prob...@druide.com> wrote:
>>
>> Ahhh… If I change the factory in the node definition to 
>> org.apache.cayenne.configuration.server.PropertyDataSourceFactory, it does 
>> read the command-line properties.
>
> That should sorta happen automatically. We are still looking why it doesn't.
>
> Andrus
>



-- 
Best regards,
Nikita Timofeev

Reply via email to