-
Type:
New Feature
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: Model
-
None
Decision
Map Hibernate table qualifiers onto MongoDB:
- @Table.schema -> a prefix on the collection name (schema s + table t -> collection s.t) within the single database bound to the SessionFactory. Cross-schema joins and multi-collection transactions work because everything is co-located.
- @Table.catalog and hibernate.default_catalog -> rejected at boot. A MongoDB database is the analog of a SQL catalog; routing a catalog to a separate database is deferred to HIBERNATE-209. Use one SessionFactory per database in the meantime.
Implemented by reporting NameQualifierSupport.SCHEMA from the dialect, plus boot-time checks rejecting catalog and fold-induced collection-name collisions. Full design note: docs/design-notes/HIBERNATE-39-schema-qualification.md.
Change of direction
The original request (below) framed this as "collections from different MongoDB databases." That literal goal – multiple physical databases from one SessionFactory – is not delivered here; it is split out to HIBERNATE-209, because MongoDB does not yet support cross-database $lookup, so entities in different databases could not be joined. This ticket delivers @Table.schema as collection-name namespacing within one database, which is what schema-annotated relational apps need and which keeps joins working.
Original request
It looks like we are going to require ConnectionString.getDatabase to be specified, forbid specifying @Table.schema, and use ConnectionString.getDatabase instead everywhere. This approach does not seem to be based on any hard reasons, and the product should support using MongoDB collections from different MongoDB databases. See https://github.com/mongodb/mongo-hibernate/pull/8#discussion_r1841335136 (and further comments) for more details.
- is related to
-
HIBERNATE-209 Support multiple MongoDB databases via @Table.catalog
-
- Needs Triage
-
- related to
-
HIBERNATE-38 Design, implement and document how an application can configure the product
-
- Closed
-