Skip to content
This repository has been archived by the owner on Nov 28, 2024. It is now read-only.

OGM-1589: Add hibernate-ogm metadata to MongoClient construction #1135

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
import com.mongodb.MongoDriverInformation;
import com.mongodb.MongoException;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.MongoDatabase;

import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.engine.jndi.spi.JndiService;
import org.hibernate.ogm.cfg.impl.Version;
import org.hibernate.ogm.cfg.spi.Hosts;
import org.hibernate.ogm.datastore.mongodb.MongoDBDialect;
import org.hibernate.ogm.datastore.mongodb.binarystorage.GridFSStorageManager;
Expand Down Expand Up @@ -160,7 +162,11 @@ protected MongoClient createMongoClient(MongoDBConfiguration config) {
for ( Hosts.HostAndPort hostAndPort : config.getHosts() ) {
serverAddresses.add( new ServerAddress( hostAndPort.getHost(), hostAndPort.getPort() ) );
}
return new MongoClient( serverAddresses, credential, clientOptions );
return new MongoClient( serverAddresses, credential, clientOptions,
MongoDriverInformation.builder()
.driverName( "hibernate-ogm" )
.driverVersion( Version.getVersionString() )
.build() );
}
catch (RuntimeException e) {
throw log.unableToInitializeMongoDB( e );
Expand Down
Loading