Skip to content

A MongoDB dialect for the Hibernate ORM

License

Notifications You must be signed in to change notification settings

mongodb/mongo-hibernate

Repository files navigation

A MongoDB Dialect for the Hibernate ORM

This project aims to provide a library to seamlessly integrate MongoDB with Hibernate ORM. Hibernate ORM is a powerful Object-relational mapping tool. Due to the SQL and JDBC standards, Hibernate ORM could centralize each SQL vendor's idiosyncrasies in the so-called Hibernate Dialect. This project will include a document database member in the Hibernate's Dialect family.

Overview

MongoDB speaks MQL (MongoDB Query Language in JSON format) instead of SQL. This project creates a MongoDB Hibernate Dialect by:

  • create a JDBC adapter using MongoDB Java Driver
  • translate Hibernate's internal SQL AST into MQL

MongoDB Dialect

Development

Java 17 is the JDK version for development.

Initially Hibernate ORM v6.6 is the dependency version.

MongoDB v6 is the minimal version this dialect supports.

Build from Source

Static Code Analysis

Code Style Check

We chose Spotless as a general-purpose formatting plugin, and Palantir Java Format as a Java-specific formatting tool integrated with it.

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.

Code Quality Check

Error Prone gradle plugin is chosen for Java code qualify analysis during Java compiling phrase. NullAway is a Java NullPointerExceptions (NPEs) prevention gradle plugin integrated with Error Prone. JSpecify annotations are used to help NullAway detect potential NPEs.

Both plugins are enabled on gradle's compileJava task.

References