-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: MongoDB - Non-primitive options
PostPosted: Tue Jan 26, 2016 1:14 pm 
Newbie

Joined: Fri Nov 20, 2015 5:34 pm
Posts: 6
Hi,

I'd like to be able to provide my own SocketFactory for MongoClient to use which is usually possible by passing it to MongoClientOptions.Builder. OGM currently allows MongoClientOptions to be configured via properties with the prefix 'hibernate.ogm.mongodb.driver.' which are then set in the options builder via reflection in MongoDBConfiguration.buildOptions. My problem is that the method which builds the list of options setting methods (createSettingsMap) currently excludes all non-primitive options. I was wondering whether this restriction could potentially be lifted or if there were any alternative ways to make it use a specific instance of SocketFactory?

Thanks,
David.


Top
 Profile  
 
 Post subject: Re: MongoDB - Non-primitive options
PostPosted: Wed Jan 27, 2016 6:49 am 
Hibernate Team
Hibernate Team

Joined: Fri Sep 09, 2011 3:18 am
Posts: 295
Hi,
I've created a new JIRA for it: https://hibernate.atlassian.net/browse/OGM-975

We'll try to fix as soon as possible.
If you want to speed up the process you could try to create a fix for it; the jira contains some explanations and a patch with a test case.

As a temporary workaround you can ovverride MongoDBDatastoreProvider to create your MongoClient.

Thanks for the feedback,
Davide


Top
 Profile  
 
 Post subject: Re: MongoDB - Non-primitive options
PostPosted: Thu Jan 28, 2016 11:46 am 
Newbie

Joined: Fri Nov 20, 2015 5:34 pm
Posts: 6
Thanks Davide. We can work around this for the moment but eventually we'll need this functionality so we'll pick up the ticket at that time unless someone else gets to it first.

Thanks,
David.


Top
 Profile  
 
 Post subject: Re: MongoDB - Non-primitive options
PostPosted: Mon Feb 01, 2016 1:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hey David,

Can you tell us why you need to pass your own SocketFactory ? Looks at first sight like an unfrequent requirement so that's interesting to hear your needs.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: MongoDB - Non-primitive options
PostPosted: Thu Feb 04, 2016 2:45 pm 
Newbie

Joined: Fri Nov 20, 2015 5:34 pm
Posts: 6
Hi Emmanuel,

Our application needs to communicate with MongoDB over SSL. We're planning on deploying in Docker containers and I want our images to be non-environment specific so would like the ability to provide a reference to the SSL certificates when the container is started and for the application to programmatically retrieve the certificates and install them in a trust store. In order to use these certificates for connecting to MongoDB we'd need to use an instance of an SSLSocketFactory which used this specific trust store rather than the default one.

Dave.


Top
 Profile  
 
 Post subject: Re: MongoDB - Non-primitive options
PostPosted: Mon Feb 08, 2016 8:42 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Thanks, interesting.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Re: MongoDB - Non-primitive options
PostPosted: Wed Apr 13, 2016 9:02 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
DavidW_asdf, it should be possible to lift that restriction, but naturally this would not work when configuring Hibernate OGM through persistence.xml, hibernate.properties and the like. I.e. you'd have to bootstrap Hibernate OGM programmatically in order to pass in an actual instance of the socket factory. Out of curiousity, how are you bootstrapping it atm.?

Thanks,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
 Post subject: Re: MongoDB - Non-primitive options
PostPosted: Wed Apr 13, 2016 10:43 am 
Newbie

Joined: Fri Nov 20, 2015 5:34 pm
Posts: 6
Hi Gunnar,

We have persistence.xml files for non-environment specific settings (entities, transaction types etc) and then we bootstrap in Guice/Onami Persistence where we programmatically supplement those properties with the environment specific ones. e.g.

Code:
  protected Properties mongoDbJpaConfigurationFrom(final String dbUriProperty) {
    final MongoDbConfig config = MongoDbConfig.fromURI(getProperty(dbUriProperty));
    Properties properties = new Properties();
    properties.put("hibernate.ogm.datastore.database", config.getDatabase());
    properties.put("hibernate.ogm.datastore.host", config.toHostAddress());
    properties.put("hibernate.ogm.datastore.username", config.getUsername());
    properties.put("hibernate.ogm.datastore.password", config.getPassword());
    properties.put("org.hibernate.flushMode", "COMMIT");

    if(config.isSsl()) {
      properties.put("hibernate.ogm.mongodb.driver.sslEnabled", true);
      properties.put("hibernate.ogm.mongodb.driver.sslInvalidHostNameAllowed", true);
      // TODO: add certificate import
    }

    return properties;
  }


Thanks,
Dave.


Top
 Profile  
 
 Post subject: Re: MongoDB - Non-primitive options
PostPosted: Thu Apr 14, 2016 6:30 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Thanks for the reply, Dave; Then we should be able to get this working.

Note there is OgmProperties which defines constants for most of the properties, so you don't need to write out those as Strings.

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.