|
1 | 1 | # MongoDB Extension for Hibernate ORM |
2 | 2 |
|
3 | | -This product enables applications to use databases managed by the [MongoDB](https://www.mongodb.com/) DBMS |
4 | | -via [Hibernate ORM](https://hibernate.org/orm/). |
| 3 | +<p align="right"> |
| 4 | + <a href="https://docs.oracle.com/en/java/javase/17/"> |
| 5 | + <img src="https://img.shields.io/badge/Java_SE-17+-E49639.svg?labelColor=32728B" |
| 6 | + alt="Java SE requirement"> |
| 7 | + </a> |
| 8 | + <a href="https://hibernate.org/orm/documentation/6.6/"> |
| 9 | + <img src="https://img.shields.io/badge/Hibernate_ORM-6.6-BAAE80.svg?labelColor=5C656C" |
| 10 | + alt="Hibernate ORM requirement"> |
| 11 | + </a> |
| 12 | + <a href="https://www.mongodb.com/docs/manual/"> |
| 13 | + <img src="https://img.shields.io/badge/MongoDB_-7.0+-00ED64.svg?labelColor=001E2B" |
| 14 | + alt="MongoDB DBMS requirement"> |
| 15 | + </a> |
| 16 | +</p> |
5 | 17 |
|
6 | 18 | ## Overview |
7 | 19 |
|
8 | | -MongoDB speaks MQL (**M**ongoDB **Q**uery **L**anguage) instead of SQL. This product works by: |
| 20 | +This product enables applications to use databases managed by the [MongoDB](https://www.mongodb.com/) DBMS |
| 21 | +via [Hibernate ORM](https://hibernate.org/orm/). |
| 22 | + |
| 23 | +MongoDB speaks [MQL (**M**ongoDB **Q**uery **L**anguage)](https://www.mongodb.com/docs/manual/reference/mql/) |
| 24 | +instead of SQL. This product works by: |
9 | 25 |
|
10 | 26 | - Creating a JDBC adapter using [MongoDB Java Driver](https://www.mongodb.com/docs/drivers/java-drivers/), |
11 | | - which has to be plugged into Hibernate ORM via a custom [`ConnectionProvider`](https://docs.jboss.org/hibernate/orm/6.6/javadocs/org/hibernate/engine/jdbc/connections/spi/ConnectionProvider.html). |
12 | | -- Translating Hibernate's internal SQL AST into MQL by means of a custom [`Dialect`](https://docs.jboss.org/hibernate/orm/6.6/javadocs/org/hibernate/dialect/Dialect.html), |
| 27 | + which has to be plugged into Hibernate ORM via a custom |
| 28 | + [`ConnectionProvider`](https://docs.jboss.org/hibernate/orm/6.6/javadocs/org/hibernate/engine/jdbc/connections/spi/ConnectionProvider.html). |
| 29 | +- Translating Hibernate's internal SQL AST into MQL by means of a custom |
| 30 | + [`Dialect`](https://docs.jboss.org/hibernate/orm/6.6/javadocs/org/hibernate/dialect/Dialect.html), |
13 | 31 | which has to be plugged into Hibernate ORM. |
14 | 32 |
|
15 | | -## Development |
| 33 | +## User Documentation |
16 | 34 |
|
17 | | -Java 17 is the JDK version for development. |
| 35 | +- [Manual](https://www.mongodb.com/docs/languages/java/mongodb-hibernate/current) |
| 36 | +- [API](https://javadoc.io/doc/org.mongodb/mongodb-hibernate/latest/index.html) |
18 | 37 |
|
19 | | -Initially Hibernate ORM v6.6 is the dependency version. |
| 38 | +[Standalone deployments](https://www.mongodb.com/docs/manual/reference/glossary/#std-term-standalone) are not supported, |
| 39 | +because they [do not support transactions](https://www.mongodb.com/docs/manual/core/transactions-production-consideration/). |
| 40 | +If you use one, you may [convert it to a replica set](https://www.mongodb.com/docs/manual/tutorial/convert-standalone-to-replica-set/). |
20 | 41 |
|
21 | | -MongoDB v7.0 is the minimal version this product supports. |
| 42 | +### Maven Artifacts |
22 | 43 |
|
23 | | -> [Standalone instance](https://www.mongodb.com/docs/manual/reference/glossary/#std-term-standalone) is not supported. It is recommended to [convert it to a replica set](https://www.mongodb.com/docs/manual/tutorial/convert-standalone-to-replica-set/). |
| 44 | +The `groupId:artifactId` coordinates: `org.mongodb:mongodb-hibernate`. |
24 | 45 |
|
25 | | -### Build from Source |
| 46 | + - [Maven Central Repository](https://repo.maven.apache.org/maven2/org/mongodb/mongodb-hibernate/) |
| 47 | + - [Maven Central Repository Search](https://central.sonatype.com/artifact/org.mongodb/mongodb-hibernate) |
| 48 | + |
| 49 | +### Bug Reports |
26 | 50 |
|
27 | | -#### Static Code Analysis |
| 51 | +Use ["Extension for Hibernate ORM" at jira.mongodb.org](https://jira.mongodb.org/projects/HIBERNATE/issues). |
28 | 52 |
|
29 | | -#### Code Style Check |
| 53 | +### Feature Requests |
30 | 54 |
|
31 | | -We chose [Spotless](https://github.com/diffplug/spotless/tree/main/plugin-gradle) as a general-purpose formatting plugin, and [Palantir Java Format](https://github.com/palantir/palantir-java-format) as a Java-specific formatting tool integrated with it. |
| 55 | +Use ["Drivers & Frameworks"/"Frameworks (e.g. Django, Hibernate, EFCore)" at feedback.mongodb.com" at feedback.mongodb.com](https://feedback.mongodb.com/?category=7548141831345841376). |
32 | 56 |
|
33 | | -To check whether any format violation exists, run `spotlessCheck` gradle task. If any format violation is found during the previous step, run `spotlessApply` auto-formatting task to fix it automatically. |
| 57 | +## Contributor Documentation |
34 | 58 |
|
35 | | -#### Code Quality Check |
| 59 | +[Gradle](https://gradle.org/) is used as a build tool. |
36 | 60 |
|
37 | | -[Error Prone](https://github.com/tbroyer/gradle-errorprone-plugin) gradle plugin is chosen for Java code qualify analysis during Java compiling phrase. [NullAway](https://github.com/uber/NullAway) is a Java `NullPointerException`s (NPEs) prevention gradle plugin integrated with Error Prone. [JSpecify](https://jspecify.dev) annotations are used to help NullAway detect potential NPEs. |
| 61 | +### Build from Source |
38 | 62 |
|
39 | | -Both plugins are enabled on gradle's `compileJava` task. |
| 63 | +```console |
| 64 | +./gradlew clean build |
| 65 | +``` |
40 | 66 |
|
41 | | -### Testing |
| 67 | +### Static Code Analysis |
42 | 68 |
|
43 | | -This project uses separate directories for unit and integration tests: |
| 69 | +#### Code Formatting |
44 | 70 |
|
45 | | -- [unit test](src/test) |
46 | | -- [integration test](src/integrationTest) |
| 71 | +[Spotless](https://github.com/diffplug/spotless) |
| 72 | +[Gradle plugin](https://github.com/diffplug/spotless/tree/main/plugin-gradle) is used as a general-purpose formatting tool, |
| 73 | +[Palantir Java Format](https://github.com/palantir/palantir-java-format) is used as a Java-specific formatting tool |
| 74 | +integrated with it. |
47 | 75 |
|
48 | | -#### Gradle Tasks |
| 76 | +##### Check Code Formatting |
49 | 77 |
|
50 | | -##### Unit Test |
51 | 78 | ```console |
52 | | -./gradlew clean test |
| 79 | +./gradlew spotlessCheck |
53 | 80 | ``` |
54 | 81 |
|
55 | | -##### Integration Test |
| 82 | +##### Format Code |
| 83 | + |
56 | 84 | ```console |
57 | | -./gradlew clean integrationTest |
| 85 | +./gradlew spotlessApply |
58 | 86 | ``` |
59 | 87 |
|
60 | | -Integration tests require a MongoDB deployment with test commands enabled, |
61 | | -which may be achieved with the |
| 88 | +#### Code Quality |
| 89 | + |
| 90 | +[Error Prone](https://errorprone.info/) [Gradle plugin](https://github.com/tbroyer/gradle-errorprone-plugin) |
| 91 | +is used as a Java-specific code analysis tool, |
| 92 | +[NullAway](https://github.com/uber/NullAway) is used as a |
| 93 | +[`NullPointerException`](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/NullPointerException.html) |
| 94 | +prevention tool integrated with it. [JSpecify](https://jspecify.dev) annotations are used to specify nullness. |
| 95 | + |
| 96 | +The analysis is done as part of the Gradle `compileJava` task execution. |
| 97 | + |
| 98 | +### Testing |
| 99 | + |
| 100 | +This project uses separate directories for unit and integration tests: |
| 101 | + |
| 102 | +- [`./src/test`](src/test) |
| 103 | +- [`./src/integrationTest`](src/integrationTest) |
| 104 | + |
| 105 | +Integration tests require a MongoDB deployment with test commands enabled, which may be achieved with the |
62 | 106 | [`--setParameter enableTestCommands=1`](https://www.mongodb.com/docs/manual/reference/parameters/) |
63 | 107 | command-line arguments. |
64 | | -You may change the default [MongoDB connection string](https://www.mongodb.com/docs/manual/reference/connection-string/) as below, in [hibernate.properties](src/integrationTest/resources/hibernate.properties): |
65 | 108 |
|
66 | | -```properties |
67 | | -jakarta.persistence.jdbc.url={your_mongodb_connection_string} |
| 109 | +You may change the [MongoDB connection string](https://www.mongodb.com/docs/manual/reference/connection-string/) |
| 110 | +via the [`jakarta.persistence.jdbc.url`](https://docs.hibernate.org/orm/6.6/userguide/html_single/#settings-jakarta.persistence.jdbc.url) |
| 111 | +configuration property |
| 112 | +in [`./src/integrationTest/resources/hibernate.properties`](src/integrationTest/resources/hibernate.properties). |
| 113 | + |
| 114 | +#### Run Unit Tests |
| 115 | + |
| 116 | +```console |
| 117 | +./gradlew test |
68 | 118 | ``` |
69 | 119 |
|
70 | | -### CI/CD |
71 | | -This project uses [evergreen](https://github.com/evergreen-ci/evergreen), a distributed continuous integration system from MongoDB. The evergreen configuration is in the [.evergreen](/.evergreen) directory. |
| 120 | +#### Run Integration Tests |
| 121 | + |
| 122 | +```console |
| 123 | +./gradlew integrationTest |
| 124 | +``` |
72 | 125 |
|
73 | | -## References |
74 | | -- [An Introduction to Hibernate 6](https://docs.jboss.org/hibernate/orm/6.6/introduction/html_single/Hibernate_Introduction.html) |
75 | | -- [A Guide to Hibernate Query Language](https://docs.jboss.org/hibernate/orm/6.6/querylanguage/html_single/Hibernate_Query_Language.html) |
76 | | -- [Hibernate User Guide](https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html) |
| 126 | +### Continuous Integration |
| 127 | +[Evergreen](https://github.com/evergreen-ci/evergreen) and [GitHub actions](https://docs.github.com/en/actions) |
| 128 | +are used for continuous integration. |
0 commit comments