Skip to content

Commit

Permalink
update MongoConnectionProvider as per code review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanQingyangXu committed Nov 9, 2024
1 parent 8ac4c4f commit 5999033
Showing 1 changed file with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package com.mongodb.hibernate.jdbc;

import static org.hibernate.cfg.JdbcSettings.*;
import static org.hibernate.cfg.JdbcSettings.JAKARTA_JDBC_PASSWORD;
import static org.hibernate.cfg.JdbcSettings.JAKARTA_JDBC_URL;
import static org.hibernate.cfg.JdbcSettings.JAKARTA_JDBC_USER;

import com.mongodb.ConnectionString;
import com.mongodb.MongoClientSettings;
Expand All @@ -42,15 +44,35 @@
* <p>{@link MongoConnectionProvider} uses the following Hibernate properties:
*
* <ul>
* <li>{@linkplain org.hibernate.cfg.JdbcSettings#JAKARTA_JDBC_URL jakarta.persistence.jdbc.url}
* <li>{@linkplain org.hibernate.cfg.JdbcSettings#JAKARTA_JDBC_USER jakarta.persistence.jdbc.user}
* <li>{@linkplain org.hibernate.cfg.JdbcSettings#JAKARTA_JDBC_PASSWORD jakarta.persistence.jdbc.password}
* <li>{@linkplain JdbcSettings#JAKARTA_JDBC_URL jakarta.persistence.jdbc.url}
* <li>{@linkplain JdbcSettings#JAKARTA_JDBC_USER jakarta.persistence.jdbc.user}
* <li>{@linkplain JdbcSettings#JAKARTA_JDBC_PASSWORD jakarta.persistence.jdbc.password}
* </ul>
*
* <p>{@value org.hibernate.cfg.JdbcSettings#JAKARTA_JDBC_URL} property is mandatory and it maps to MongoDB's <a
* <p>{@value JdbcSettings#JAKARTA_JDBC_URL} property is mandatory and it maps to MongoDB's <a
* href="https://www.mongodb.com/docs/manual/reference/connection-string/">connection string</a>, in which database name
* must be provided to align with JDBC URL's convention. The other two JDBC properties are optional.
*
* <table>
* <tr><th>Property</th><th>Description</th><th>Required</th></tr>
* <tr>
* <td>{@linkplain JdbcSettings#JAKARTA_JDBC_URL jakarta.persistence.jdbc.url}</td>
* <td>MongoDB
* <a href="https://www.mongodb.com/docs/manual/reference/connection-string/">connection string</a></td>
* <td>✓</td>
* </tr>
* <tr>
* <td>{@linkplain JdbcSettings#JAKARTA_JDBC_USER jakarta.persistence.jdbc.user}</td>
* <td>{@code userName} for {@link com.mongodb.MongoCredential#createCredential(String, String, char[])}</td>
* <td></td>
* </tr>
* <tr>
* <td>{@linkplain JdbcSettings#JAKARTA_JDBC_PASSWORD jakarta.persistence.jdbc.password}</td>
* <td>{@code password} for {@link com.mongodb.MongoCredential#createCredential(String, String, char[])}</td>
* <td></td>
* </tr>
* </table>
*
* @see ConnectionProvider
* @see JdbcSettings#JAKARTA_JDBC_URL
* @see JdbcSettings#JAKARTA_JDBC_USER
Expand Down

0 comments on commit 5999033

Please sign in to comment.