I am trying to connect to the mongodb using hibernate ogm but unable to do so.
user is created from test db (other than admin db)
I am using programatic way of configuration
this is my code
cmonLog.debugLogAlways(className, "loadDBConfiguration", "", "", "Method called.");
try {
StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder();
cmonLog.debugLog(className, "loadConfiguration", "", "", "registryBuilder has created successfully.");
registryBuilder.applySetting(OgmProperties.ENABLED, true);
registryBuilder.applySetting(AvailableSettings.PERSISTENCE_UNIT_NAME, "NOSQL-DB");
// assuming you are using JTA in a non container environment
registryBuilder.applySetting(AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta");
// assuming JBoss TransactionManager in standalone mode
registryBuilder.applySetting(AvailableSettings.JTA_PLATFORM, "JBossTS");
registryBuilder.applySetting(OgmProperties.DATASTORE_PROVIDER, configuration.getDatastoreProvider());
registryBuilder.applySetting(OgmProperties.CREATE_DATABASE, false);
registryBuilder.applySetting(OgmProperties.DATABASE, configuration.getDatabase());
registryBuilder.applySetting(OgmProperties.HOST, configuration.getUrl());
// if no username / password is configured
if (configuration.getUserName() != null && configuration.getPassword() != null) {
cmonLog.debugLog(className, "loadConfiguration", "", "", "username & password is not null. setting these properties in registryBuilder");
registryBuilder.applySetting(OgmProperties.USERNAME, configuration.getUserName());
registryBuilder.applySetting(OgmProperties.PASSWORD, configuration.getPassword());
}
StandardServiceRegistry registry = registryBuilder.build();
// build the SessionFactory
MetadataSources metadataSources = new MetadataSources(registry);
Metadata metadata = metadataSources.buildMetadata();
SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder();
OgmSessionFactoryBuilder ogmSessionFactoryBuilder = sessionFactoryBuilder.unwrap(OgmSessionFactoryBuilder.class);
sessionFactory = ogmSessionFactoryBuilder.build();
entityManager = sessionFactory.createEntityManager();
cmonLog.debugLog(className, "loadDBConfiguration", "", "", "Configuration successfully configured.");
} catch (Exception e) {
cmonLog.stackTraceLog(className, "loadDBConfiguration", "", "", "Configuration is not configure correctly. Hence closing the monitor. exception = ", e);
closeMonitor();
return false;
}
return true;
is there any way to configure authenticationDatabase