For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
See how MongoDB 9.0 delivers up to 2x higher throughput.
MongoDB Branding Shape
Register now >
Docs Menu

Feature Compatibility

On this page, you can find information about supported and unsupported features in the Hibernate ORM extension. The Hibernate ORM extension supports only MongoDB replica sets. When you use an unsupported feature, the Hibernate ORM extension throws an UnsupportedFeatureException.

You can request support for a feature by creating an AHA idea. We prioritize upcoming features based on user demand.

This section indicates whether the Hibernate ORM extension supports various MongoDB features.

To see a list of all BSON types supported in the Hibernate ORM extension, see the MongoDB BSON Fields section in the Create Entities guide.

MongoDB Feature
General Availability (GA) Support

Bulk Writes

✓

Delete Operations

✓

Geospatial Queries

Unsupported. However, the createNativeQuery() method supports geospatial queries. Include the $geoWithin or $near pipeline stage in your MongoDB Query Language statement. To learn more about native queries, see the Perform Native Database Queries guide.

Insert Operations

✓

MongoDB Search Queries

Unsupported. However, the createNativeQuery() method supports Search queries. Include the $search pipeline stage in your MongoDB Query Language statement. To view an example, see the Run a MongoDB Search Query section in the Perform Native Database Queries guide.

MongoDB Vector Search Queries

Unsupported. However, the createNativeQuery() method supports Vector Search queries. Include the $vectorSearch pipeline stage in your MongoDB Query Language statement. To learn more about native queries, see the Perform Native Database Queries guide.

Native Querying With MQL

✓

Projections

Partially Supported. Aggregation expressions within query projections are not supported, and you must include all entity fields in your projection.
When the terminal $project stage does not specify _id, the Hibernate ORM extension excludes _id from the results instead of returning it implicitly. A native query that binds its results to an entity must project _id explicitly.

Read Operations

✓

Update Operations

✓

Upsert Operations

Partially Supported. Upsert operations are supported on unversioned entities through the StatelessSession API. Does not support entities that have a field annotated with @Version. To learn more, see the Upsert Documents section in the Perform CRUD Operations guide.

MongoDB Feature
General Availability (GA) Support

Change Streams

Unsupported. However, you can use a change stream through the MongoDB Java Driver. To learn more, see the Open Change Streams section in the Java Driver documentation.

Client-side Field Level Encryption (CSFLE) and Queryable Encryption (QE)

Unsupported. We are considering this feature for future release. However, you can setup CSFLE/QE when you configure the MongoDB Java Driver. To learn more, see the CSFLE documentation in the MongoDB Server manual.

GridFS

Unsupported. However, you can use GridFS through the MongoDB Java Driver. To learn more, see the Large File Storage with GridFS guide in the Java Driver documentation.

Time Series Data

Unsupported. However, you can create a time series collection through the MongoDB Java Driver. To learn more, see the Time Series Collections guide in the Java Driver documentation.

Standalone mongod Instances

Unsupported. We recommended that you convert any standalone instances to a replica set. To learn more, see Convert a Standalone Self-Managed mongod to a Replica Set in the MongoDB Server manual.

Views

Unsupported. However, you can use the MongoDB Java Driver to define a MongoClient instance. Then, call the createView() method on your MongoDatabase instance to create a new view.

MongoDB Feature
General Availability (GA) Support

Locking

Partially Supported. Optimistic locking is supported on entities that have a field annotated with @Version. The Hibernate ORM extension adds the current version value to the MQL filter for each update and delete, and throws an OptimisticLockException when the version no longer matches. To learn more, see the Prevent Conflicting Updates with Optimistic Locking guide.

Does not support Pessimistic Locking.

Transactions

✓

MongoDB Feature
General Availability (GA) Support

Associations

Partially Supported. The @OneToOne, @OneToMany, @ManyToOne, @ManyToMany, and @ElementCollection annotations are supported. The @SecondaryTable and @JoinFormula annotations are not supported, and cause an error when the SessionFactory starts.

Autogenerating IDs

Partially Supported. Autogenerating ObjectIds is supported. However, you can manually set String and int identifiers.

The @GeneratedValue annotation supports sequence-style generation, which the Hibernate ORM extension backs with a counter collection named hibernate_sequences.

Autogenerating java.util.UUID identifiers is supported through the @UuidGenerator annotation or the @GeneratedValue(strategy = UUID) annotation.

Does not support the IDENTITY and TABLE strategies, BigInteger and BigDecimal identifiers, and a non-blank @SequenceGenerator options element.

Composite Primary Keys

Partially Supported. Declare a composite key with @EmbeddedId on a standard @Embeddable class or record. The Hibernate ORM extension stores the key as an _id sub-document and never generates its value.

Does not support the @IdClass annotation, multiple @Id attributes, a @Struct aggregate embeddable identifier, a non-scalar key component, and derived identity through @MapsId.

To learn more, see the Composite Primary Keys section in the Create Entities guide.

Inheritance Strategy

Partially Supported. Single-table inheritance and mapped superclasses are supported. Does not support the JOINED and TABLE_PER_CLASS strategies. To learn more, see the Map an Entity Inheritance Hierarchy guide.

@JdbcTypeCode Annotation

Unsupported.

Lazy/Eager Fetching

Unsupported.

Ordering

✓

@Table.catalog Element

Unsupported. The Hibernate ORM extension rejects the @Table.catalog element and the hibernate.default_catalog property at bootstrap because MongoDB does not support cross-database $lookup operations. Create one SessionFactory instance for each database instead.

@Table.schema Element

✓
Maps to a collection-name prefix within a single MongoDB database.

Validation

✓

MongoDB Feature
General Availability (GA) Support

Capped Collections

Unsupported. However, you can use the MongoDB Java Driver to define a MongoClient instance. Then, create a capped collection by specifying CreateCollectionOptions.capped(true) as a parameter in your createCollection() call.

Clustered Collections

Unsupported. However, you can use the MongoDB Java Driver to define a MongoClient instance. Then, create a document called clusteredIndex and define your clustered index. Use this clustered index as a part of the document you pass to the MongoDatabase.runCommand() method, which defines the clustered collection.

Compound Indexes

✓

Embedded Document Indexes

Unsupported. However, you can use the MongoDB Java Driver to define a MongoClient instance. Then, call the nested method MongoCollection.createIndex(Indexes.ascending("field.subfield")). This method uses nested key paths "field.subfield" to create an embedded document index.

Geospatial Indexes

Unsupported. However, you can use geospatial indexes through the MongoDB Java Driver. To learn more, see the Geospatial Indexes section of the Indexes guide in the Java Driver documentation.

MongoDB Search Indexes

Unsupported. However, you can use MongoDB Search indexes through the MongoDB Java Driver. To learn more, see the MongoDB Search and Vector Search Indexes section of the Indexes guide in the Java Driver documentation.

MongoDB Vector Search Indexes

Unsupported. However, you can use MongoDB Vector Search indexes through the MongoDB Java Driver. To learn more, see the MongoDB Search and Vector Search Indexes section of the Indexes guide in the Java Driver documentation.

Multikey Indexes

Unsupported. However, you can use multikey indexes through the MongoDB Java Driver. To learn more, see the Multikey Indexes (Indexes on Array Fields) section of the Indexes guide in the Java Driver documentation.

Partial Indexes

Unsupported. However, you can use the MongoDB Java Driver to define a MongoClient instance. Then, call the nested method MongoCollection.createIndex(Indexes.partialFilterExpression()) to create a partial index.

Schema Validation

Unsupported. However, you can use the MongoDB Java Driver to define a MongoClient instance. Then, create a validator by executing the collMod command through the MongoDatabase.runCommand() method.

Single Field Indexes

✓

Sparse Indexes

Unsupported. However, you can use the MongoDB Java Driver to define a MongoClient instance. Then, specify IndexOptions().sparse(true) as a parameter in your call to the MongoCollection.createIndex() method to create a sparse index.

Unique Indexes

✓

Updating Embedded Model Indexes After Model Creation

Unsupported. However, you can drop and recreate the embedded model index manually.

To learn more about indexes, see the Indexes for Query Optimization guide.

This section indicates whether the Hibernate ORM extension supports various Hibernate ORM Features.

Data Type
General Availability (GA) Support

Collection Types (List, Set, Maps, Arrays)

✓
@ElementCollection and CollectionTable are not supported. However, collections of embedded structs are supported through embeddable classes annotated with @Embeddable and @Struct.

Embeddable Entities, Scalar Types

Partially Supported. The java.time.Instant, java.time.Duration, java.time.Year, java.time.ZoneId, java.time.ZoneOffset, and java.util.TimeZone types are supported for top-level and nested entities.

Embedded Entities, Binary

✓

Embedded Entities, Identifier Types

Partially Supported. Manually set the ID of an entity before persisting an entity.

Embedded Entities, JSON

✓

Embedded Entities, Null Semantics

✓

Top-level Entities, Binary

✓

Top-level Entities, Identifier Types

✓
Manually assign UUIDs before persisting an entity, or autogenerate them by using the @UuidGenerator annotation.

Top-level Entities, JSON

✓

Top-level Entities, Null Semantics

✓

Top-level Entities, Scalar Types

✓

Top-level Entities, Temporal Types

Partially Supported. The java.time.Instant, java.time.Duration, java.time.Year, java.time.ZoneId, java.time.ZoneOffset, and java.util.TimeZone types are supported for top-level and nested entities.

Ternary Logic (True, False, or UNKNOWN)

Unsupported.

The Hibernate ORM extension requires you to set the com.mongodb.hibernate.semantics.nulls property, and MQL is the only supported value. Null comparisons follow MongoDB Query Language semantics rather than Hibernate ORM ternary logic. The Hibernate ORM extension throws an exception at startup when the property is not set.

Hibernate ORM Feature
General Availability (GA) Support

HQL and JPQL Queries, Aggregate Operators

✓

HQL and JPQL Queries, Arithmetic Operators

Partially Supported. Supports the +, -, *, /, div operators, and unary - and + in the SELECT and WHERE clauses.

Does not support function calls as operands, including the HQL % operator, which Hibernate ORM rewrites to a mod() function call.

To learn more, see the Use Computed Expressions section in the Specify a Query guide.

HQL and JPQL Queries, Array Operators

✓

HQL and JPQL Queries, Datetime Functions

Partially Supported. Supports the extract() and format() functions on a datetime field in a SELECT clause, translating them to MongoDB date operators and the $dateToString operator. Each function supports a specific set of datetime fields and pattern codes. To learn more, see the Use Datetime Functions in Queries guide.

HQL and JPQL Queries, String Functions

Partially Supported. Supports the length(), upper(), lower(), concat(), substring(), locate(), replace(), trim(), pad(), and repeat() functions and the || operator on a string field in a SELECT clause, translating them to MongoDB string operators. Does not support the position(), overlay(), left(), right(), or collate() functions. For more information and to view examples, see the Use String Functions in Queries guide.

HQL and JPQL Queries, Case Expressions

Partially Supported.

  • Supports simple and searched CASE expressions in a SELECT clause, as an operand of a comparison in a WHERE clause, and in the SET clause of a bulk update statement. Translates them to the MongoDB $switch operator.

  • Does not support CASE expressions in an ORDER BY clause, unless the same CASE expression is a GROUP BY key. Additionally, does not support CASE expressions as the match expression of a LIKE predicate, as the test expression of an IN or IS NULL predicate, or as a WHERE clause predicate.

For more information and to view an example, see the Use Case Expressions for Conditional Logic section in the Specify a Query guide.

HQL and JPQL Queries, Comparison Operators

  • >, >=, <, <=, =, <>: Supported, including with computed operands. To learn more, see the Use Computed Expressions section in the Specify a Query guide.

  • EXISTS: Partially Supported. Supports an EXISTS subquery that filters on elements of a single field's embedded array, translating it to the MongoDB $elemMatch operator. Does not support certain EXISTS subqueries. To learn more, see the EXISTS section in the Specify a Query guide.

  • BETWEEN: Supported. Translates to the MongoDB $gte and $lte operators. To learn more, see the BETWEEN section in the Specify a Query guide.

  • IS NULL and IS NOT NULL: Supported. Matches explicitly null values and missing fields or the negation of those values, translating to the MongoDB $match operator. To learn more, see the IS NULL and IS NOT NULL sections in the Specify a Query guide.

  • IN and NOT IN: Partially Supported. Supports a list of literals or parameters tested against a field path, translating to the MongoDB $in and $nin operators. Does not support a subquery or an array-valued expression as the list. To learn more, see the IN and NOT IN sections in the Specify a Query guide.

  • Comparisons to null: Supported. Applies MongoDB Query Language null semantics rather than Hibernate ORM ternary logic, so a comparison to null matches explicitly null values and missing fields. To learn more, see the Compare Field Values to Null section in the Specify a Query guide.

  • Row-value predicates: Partially Supported. Supports the =, <>, IN, and NOT IN operators over a parenthesized list of fields, such as where (title, year) = (:t, :y), translating each predicate to per-component MongoDB $eq comparisons. Does not support row-value predicates that use the >, >=, <, or <= operator. To learn more, see the Compare Multiple Fields at Once section in the Specify a Query guide.

  • LIKE: Supported. Translates to the MongoDB $regex operator.

  • ANY, ALL: Unsupported. You can use the createNativeQuery() method and pass comparison operators in your MongoDB Query Language statement. To learn more about native queries, see the Perform Native Database Queries guide.

HQL and JPQL Queries, Element Operators

✓

HQL and JPQL Queries, Evaluation Operators

Partially Supported. Supports the MongoDB $regex evaluation operator by translating the LIKE, NOT LIKE, ILIKE, and NOT ILIKE predicates to regular expression filters. For more information and to view examples, see the LIKE section in the Specify a Query guide.

HQL and JPQL Queries, Grouping

Partially Supported. Supports the GROUP BY and HAVING clauses, which translate to the MongoDB $group and $match stages. A grouping key can be a field reference or a computed expression. For more information and to view examples, see the Group Results section in the Modify Query Results guide.

  • Field reference keys: Supported, including fields of @Struct aggregate embeddables and joined entities.

  • Aggregate functions over a @Struct aggregate embeddable: Unsupported. You can apply an aggregate function to a field of an embeddable, as in count(a.intField), but not to the embeddable itself, as in count(a).

  • Computed expression keys: Supported. An expression in the SELECT or HAVING clause resolves to a grouping key only when you write the two identically.

  • Stray columns: Unsupported. Every column in the SELECT, HAVING, or ORDER BY clause must be a grouping key or contained in one.

  • ORDER BY over a grouping key: Supported, for both field reference keys and computed expression keys.

  • SELECT DISTINCT with GROUP BY: Unsupported.

HQL and JPQL Queries, Joins

Partially Supported. You can join entities by navigating a mapped association, as in from Movie m join m.comments c, or by naming an entity and supplying an ON clause, as in from Movie m join Comment c on c.date > m.released. Each join translates to a MongoDB $lookup and $unwind stage. To view examples, see the Join Entities Across Collections guide.

  • Inner and left outer joins: Supported.

  • JOIN FETCH clauses: Supported.

  • Chained joins: Supported. You can join across more than two entities.

  • Composite key joins: Partially Supported. You can join a @ManyToOne or @OneToOne association whose target entity has an @EmbeddedId composite key. You can also compare whole composite identifiers with = in an ON condition.

    Does not support the @JoinColumn annotation on such an association, ordering comparisons between whole identifiers, and @ManyToMany associations that involve a composite key.

    To learn more, see the Composite Key Joins section in the Join Entities Across Collections guide.

  • ON conditions: Partially Supported. An ON condition supports the same comparison, logical, and predicate operators as a WHERE clause. This includes compound conditions that combine multiple field comparisons with AND or OR, and range and inequality conditions. An ON condition must compare columns. You cannot compare entity references, as in on m = c.movie, or navigate an association within the condition, as in on c.movie.title = 'Blue Jasmine'.

  • Right outer, full outer, cross, lateral, and subquery joins: Unsupported. You can use the createNativeQuery() method to run an aggregation operation that queries multiple collections. To learn more about native queries, see the Perform Native Database Queries guide.

HQL and JPQL Queries, Logical Operators

✓

HQL and JPQL Queries, String Functions

Partially Supported. Supports the character_length(), length(), substring(), trim(), upper(), lower(), pad(), lpad(), rpad(), concat(), locate(), and repeat() functions, and the || concatenation operator. Other Hibernate ORM string functions are unsupported.

Hibernate ORM Feature
General Availability (GA) Support

First-Level Cache

✓

Second-Level Cache

✓

This section indicates whether the Hibernate ORM extension supports various external frameworks or libraries.

Framework or Library
General Availability (GA) Support

Spring Boot and Spring Data JPA

Partially Supported. The Hibernate ORM extension provides a Spring Boot starter that configures MongoDB-backed JPA and Spring Data JPA repositories. We do not guarantee support for all Spring Boot or Spring Data features. To learn more, see the Spring Boot and Spring Data JPA Integration section.